User Tools

Site Tools


ustring.htm
Navigation:  Language Reference > 3 - Variable Declarations > Data Types >====== USTRING (Unicode string) ====== Previous pageReturn to chapter overviewNext page
length
label USTRING ( string constant ) [,DIM( )] [,OVER( )] [,NAME( )] [,EXTERNAL] [,DLL]
picture [,STATIC] [,THREAD] [,AUTO] [,PRIVATE] [,PROTECTED]

blk2blue.jpg

USTRING A Unicode character string.

Format: A fixed number of bytes.

Size:   4MB at design time. Can be extended using NEW at runtime.

length A numeric constant that defines the maximum number of characters in the string. This must include the terminating null character.
string constant A string constant containing the initial value of the string. The length of the string is set to the length of the string constant plus the terminating character. To define a Unicode string literal you must use the U specifier to tell the compiler that the static string is Unicode text (see details below).
picture The picture token used to format the values assigned to the string. The length of the string is the number of bytes needed to contain the formatted string plus the terminating character. Ustring variables are not initialized unless given a string constant.
DIM Dimension the variable as an array.
OVER Share a memory location with another variable.
NAME Specify an alternate, “external” name for the field.
EXTERNAL Specify the variable is defined, and its memory is allocated, in an external library. Not valid within FILE, QUEUE, or GROUP declarations.
DLL Specify the variable is defined in a .DLL. This is required in addition to the EXTERNAL attribute.
STATIC Specify the variable's memory is permanently allocated.
THREAD Specify memory for the variable is allocated once for each execution thread. Also implicitly adds the STATIC attribute on Procedure Local data.
AUTO Specify the variable has no initial value.
PRIVATE Specify the variable is not visible outside the module containing the CLASS methods. Valid only in a CLASS.
PROTECTED Specify the variable is not visible outside base CLASS and derived CLASS methods. Valid only in a CLASS.

USTRING declares a Unicode character string terminated by a null character (ASCII zero). The length parameter declares the number of characters (minus 1 for the for the null character) that the USTRING can contain.  The memory allocated is double the declared size (2 bytes per character). The memory assigned to the USTRING is initialized to a zero length string unless the AUTO attribute is present.

A USTRING can contain both Unicode and ANSI characters. To define a Unicode string literal you must use the U specifier to tell the compiler that the static string is Unicode text. The specifier can be upper U or lower case  u and must be placed immediately before the apostrophe. For example:

UST USTRING(U'Ω')   ! define a Unicode string literal

or

UST USTRING(u'Ω')          ! define a Unicode string literal

You can address multiple characters within a USTRING using the “string slicing” technique. This technique performs similar action to the SUB function, but does no bounds checking so care must be used. String slicing is not allowed on the left side of assignments.

ustring.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1