Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Passing strings – PB Docs 2022 – PowerBuilder Library

Passing strings – PB Docs 2022

Passing strings

PowerBuilder assumes all string arguments and returned values
use Unicode encoding. If a function uses strings with ANSI encoding,
you need to add an ALIAS FOR clause to the function declaration and
add a semicolon followed by the ansi keyword. For example:

Passing by value

The following statement declares the external C function NAME in
PowerBuilder. This function expects a String argument with Unicode
encoding to be passed by value:

The same statement in C would point to a buffer containing the
String:

Since the String is passed by value, the C function can change
the contents of its local copy of CODE, but the original variable in
PowerBuilder is not affected.

Passing by reference

PowerBuilder has access only to its own memory. Therefore, an
external function cannot return to PowerBuilder a pointer to a string.
(It cannot return a memory address.)

When you pass a string to an external function, either by value
or by reference, PowerBuilder passes a pointer to the string. If you
pass by value, any changes the function makes to the string are not
accessible to PowerBuilder. If you pass by reference, they are.

The following statement declares the external C function NAME2
in PowerBuilder. This function returns a String and expects a String
argument to be passed by reference:

In C, the statement would be the same as when the argument is
passed by value, shown above:

The String argument is passed by reference, and the C function
can change the contents of the argument and the original variable in
PowerBuilder. For example, Strcpy(CODE,STUMP) would change the
contents of CODE to STUMP and change the variable in the calling
PowerBuilder script to the contents of variable STUMP.

If the function NAME2 in the preceding example takes a user ID
and replaces it with the user’s name, the PowerScript string variable
CODE must be long enough to hold the returned value. To ensure that
this is true, declare the String and then use the Space function to
fill the String with blanks equal to the maximum number of characters
you expect the function to return.

If the maximum number of characters allowed for a user’s name is
40 and the ID is always five characters, you would fill the String
CODE with 35 blanks before calling the external function:

For information about the Space function, see the section called “Space” in PowerScript Reference.


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