Strings; String Expressions; Wide Strings - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Strings

A string is an array of characters of known length. This length may be less than the dimensioned length.
For example:
DEFINE_VARIABLE
CHAR MyString[32]
INTEGER StrLen
DEFINE_START
MyString = 'STOP'
StrLen = LENGTH_STRING(MyString)
In the example above,
range from 0 to 32. If an attempt is made to assign a string longer than the capacity of the destination
string, the copied string is truncated to fit. The string length is implicitly set when a string literal, string
expression, or variable is assigned to the string. The function
explicitly set the length of a string to any arbitrary length between 0 and the dimension of the character
array. Here's an example:
SET_LENGTH_STRING(MyString, 3)
This causes the contents of
MYSTRING[4]

String expressions

A string expression is a string enclosed in double quotes containing a series of constants and/or variables
evaluated at run-time to form a string result. String expressions can contain up to 16000 characters
consisting of string literals, variables, arrays, and ASCII values between 0 and 255. Here's an example:
CHAR StrExp[6]
StrExp = "STOP, 25, 'OFF', X"
In the example above, the string expression contains the constant
, and the variable
'OFF'
25, 'OFF', 5"

Wide strings

A wide character string data type is provided for dealing with Unicode fonts, which use 16-bit character
codes (used for many Far-Eastern fonts) instead of the standard 8-bit codes (used with most Western
fonts). Here's a syntax sample for a wide character string:
WIDECHAR WChar[40]
The statement above declares a wide character string containing 40 elements, for a total of 80 bytes. A
wide character string can be used in the same manner as other character strings. It maintains a length
field that can be retrieved using
example:
WIDECHAR StrExp[6]
INTEGER
StrExp = {STOP, 500, 'OFF', X}
StrLen = LENGTH_STRING(StrExp)
NetLinx Programming Language Reference Guide
holds the value 4, the length of
StrLen
to read '
MyString
.
. Assuming
X
STOP
.
LENGTH_STRING
StrLen
MyString
SET_LENGTH_STRING
', even though the character '
STO
, the value
STOP
is 2 and
= 5, the string expression will evaluate to
X
and set using
SET_LENGTH_STRING
Language Elements
. The length of
can
MyString
can be used to
' still resides in
P
, the string literal
25
"2,
. Here's an
51

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents