Types of arguments for functions and events – PB Docs 125

Types of arguments for functions and events

When you define a function or user event, you specify its
arguments, their datatypes, and how they are passed.

There are three ways to pass an argument:

  • By value

    Is the default

    PowerBuilder passes a copy of a by-value argument. Any changes
    affect the copy, and the original value is unaffected.

  • By reference

    Tells PowerBuilder to pass a pointer to the passed variable

    The function script can change the value of the variable because
    the argument points back to the original variable. An argument passed
    by reference must be a variable, not a literal or constant, so that
    it can be changed.

  • Read-only

    Passes the argument by value without making a copy of the data

    Read-only provides a performance advantage for some datatypes
    because it does not create a copy of the data, as with by value.
    Datatypes for which read-only provides a performance advantage are String, Blob, Date, Time, and DateTime.

    For other datatypes, read-only provides documentation for
    other developers by indicating something about the purpose of the
    argument.

Matching argument types when overriding functions

If you define a function in a descendant that overrides an
ancestor function, the function signatures must match in every way:
the function name, return value, argument datatypes, and argument
passing methods must be the same.

For example, this function declaration has two long arguments
passed by value and one passed by reference:

If the overriding function does not match, then when you call
the function, PowerBuilder calculates which function matches more
closely and calls that one, which might give unexpected results.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x