AMX AXCESS CONTROL SYSTEM PROGRAM Instruction Manual page 45

Programming language
Table of Contents

Advertisement

Array Manipulation Keywords (Cont.)
FIND_STRING
REMOVE_STRING
Axcess Programming Language
This keyword will search through a string for a specified sequence of charac-
ters. When a duplication of the sequence is found, it returns the beginning posi-
tion of that sequence.
The keywords explained previously are helpful when you know where certain
parts of strings are located within a string array. However, there will be times
when you don't know where certain parts of strings are located. In these cases,
the FIND_STRING keyword is used.
For example, if you don't know the exact contents of the TEMP array, but you
want to find out if it contains the string LO, (assuming that TEMP contains
HELLO) the following line is executed.
Example:
X = FIND_STRING (TEMP,'LO',1)
When Axcess executes this statement, it will search the array TEMP from the
beginning, looking for the string LO. If Axcess finds the substring, it returns the
starting position of the substring in the TEMP array: in this case, 4. The third
parameter (in this example, 1) tells Axcess where (in the string) to start the
search.
The REMOVE_STRING keyword is similar to the FIND_STRING keyword.
However, when Axcess finds the sequence it is looking for, it extracts every
character up to and including the sequence, starting from the number in the
third parameter. All other characters move up to fill in the space.
Example:
DEFINE_VARIABLE
SOURCE[2Ø]
DEST[2Ø]
DEFINE_PROGRAM
SOURCE = 'THIS IS A TEST'
DEST = REMOVE_STRING (SOURCE,'IS',1)
After the last line is executed, DEST will contain THIS, and SOURCE will con-
tain IS A TEST. Notice that after the removal, the first location of the array
SOURCE contains a space. This is because REMOVE_STRING removed all
characters from the beginning of SOURCE up to and including the string IS. It
did not remove the space following the string IS in SOURCE. Also notice that
the first occurrence of IS is embedded in the word THIS. The length values of
both arrays are set according to the results of the operation. In this case, the
length value of SOURCE is set to 4; DEST is set to 10.
In FIND_STRING, each of the first two parameters can be a string literal, a
string expression, or an array. However, in the case of REMOVE_STRING,
having anything except an array as the first parameter is illogical because
Axcess cannot remove part of a string literal or string expression, only an array
variable. This is because string literals are constant values and string expres-
sions may contain constant values. Once loaded into the Central Controller,
constant values cannot be changed, as shown in the following examples:
STR = REMOVE_STRING(TEMP,"12",1)
STR = REMOVE_STRING("2,'HELLO',1Ø,13",'HELLO',1) (* NO *)
REMOVE_STRING changes the first parameter after it removes whatever
characters it needs. Only variables can be changed at run time. Supply the
starting position of the search as the third parameter for both FIND_STRING
and REMOVE_STRING.
Arrays and Strings
(* OK *)
37

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Axcess

Table of Contents