AMX AXCESS CONTROL SYSTEM PROGRAM Instruction Manual page 43

Programming language
Table of Contents

Advertisement

PRESETS = 'FOUR
PRESETS = 'ONE'
PRESETS = "12,5,'123'"
PRESETS = "PLAY,5,Ø,'NO',X"
The length of a string array cannot exceed the number of storage locations allocated to it in the
DEFINE_VARIABLE section. For example, if the string GOODBYE is placed in the
CAM_PRESETS variable, the array will only contain the string GOODBY, dropping the final E
because CAM_PRESETS was defined to hold a maximum of six locations. The length of
CAM_PRESETS would also be set to 6. If you attempt to assign an array that exceeds the storage
allocations, the system will generate a run time error message: BAD SET LENGTH.
When string literals and string expressions are assigned, the the length of the string array is
automatically set to the length of the string literal or string expression being assigned to it.
However, assigning values to individual elements of an array does not affect the length value of the
array. For instance, if the letters W, O, R, and D are assigned individually to elements of
CAM_PRESETS, as shown below, the length will not change; if the length was previously 3, it will
still be 3.
PRESETS[1] = 'W'
PRESETS[2] = 'O'
PRESETS[3] = 'R'
PRESETS[4] = 'D'
The SET_LENGTH string keyword explicitly sets the string length value of an array variable. For
instance, to set the length value of CAM_PRESETS to 4, you would use the statement:
SET_LENGTH_STRING(CAM_PRESETS,4)
String lengths play an important role in the handling of strings. The following string expression
contains an array:
NEW_STRING = "5,TEMP,'GO'"
As Axcess constructs a string from this expression, the number of characters from NEW_STRING
it adds will equal the TEMP string's length value. If TEMP contains 1, 2, 3, 4, 5, 6, but its string
length value is 3, the resulting string from the above string expression will look like the following
example:
TEMP[1] = 1
TEMP[2] = 2
TEMP[3] = 3
TEMP[4] = 4
TEMP[5] = 5
TEMP[6] = 6
SET_LENGTH_STRING(TEMP,3)
NEW_STRING = "5,TEMP,'GO'"
The array string length is important to many Axcess string operations. This value determines how
much of the string is used when the entire array is referenced. Knowing this will prevent subtle
errors in your code. For instance, if you assign values to individual elements in an array, and then
assign that array to another, nothing is copied. For example:
Axcess Programming Language
(* LENGTH = 4 *)
(* LENGTH = 3 *)
(* LENGTH = 5 *)
(* LENGTH = 6 *)
(* NEW_STRING now equals "5,1,2,3,'G','O'" *)
Arrays and Strings
35

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AXCESS CONTROL SYSTEM PROGRAM and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Axcess

Table of Contents