Types of arguments for functions and events
When you define a function or user event, you specify its
arguments, their data types, and how they will be 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 data types
because it does not create a copy of the data, as with by value.
Data types for which read-only provides a performance advantage
are strings, blobs, date, time, and DateTime.
For other data types, read-only provides documentation for
other developers by indicating something about the purpose of the
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 data types, 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:
uf_calc(long a_1, long a_2, ref long a_3) &
If the overriding function doesn’t match, then when
you call the function PowerBuilder will calculate which function matches
more closely and call that one, which might give unexpected results.