23.4 Special Considerations for Handling Strings with
DECwindows Motif
All strings passed between DECwindows Motif and your
program must be null terminated. For example:
"A string" + "0"C
When passing a string argument to a DECwindows Motif
routine, the address of the string is required. For static
strings, the address of the string can easily be obtained with
the LOC function. For example:
COMMON (c1) STRING hierarchy_file_name = 21
hierarchy_file_name = "BASIC$HELLOMOTIF.UID" + "0"C
DECLARE LONG hierarchy_file_name_array(1)
hierarchy_file_name_array(0) = LOC (hierarchy_file_name)
Because dynamic strings are described by a descriptor, a dif-
ferent means is needed to get the address of the string text.
The following helper function will get the address of dynamic
strings as well as static strings:
FUNCTION LONG ADDRESS_OF_STRING (STRING str_arg BY REF)
OPTION TYPE=EXPLICIT, INACTIVE=SETUP
END FUNCTION (LOC (str_arg))
Example of passing a dynamic string to a DECwindows
Motif routine:
DECLARE STRING temp_string
temp_string = "A string value" + "0"C
list_test = DXmCvtFCtoCS (ADDRESS_OF_STRING (temp_string), &
byte_count, istatus)