AMX AXCESS CONTROL SYSTEM PROGRAM Instruction Manual page 83

Programming language
Table of Contents

Advertisement

Getting the data out of the buffer as soon as it enters is usually a two-step process, as shown in this
example:
DEFINE_PROGRAM
IF (LENGTH_STRING(SWT_BUFFER))
{
TEMP_CHAR = GET_BUFFER_CHAR(SWT_BUFFER)
IF (TEMP_CHAR = 'T' || TEMP_CHAR = '.')
{
SEND_STRING Ø,"'SWITCH COMMAND COMPLETE',$ØD,$ØA"
}
}
These two lines of code are actually one IF statement. The condition of the IF is the result of the
LENGTH_STRING keyword. If there are not any characters in the buffer (the length value of
SWT_BUFFER is Ø), then Axcess will skip the second part of the statement.
The second part, which will be executed if there are one or more characters in SWT_BUFFER, tells
Axcess to retrieve the first character in SWT_BUFFER, and place it into the variable CHAR, as
shown in FIG. 25.
FIG. 25 Getting the next character out of a buffer with GET_BUFFER _CHAR.
Characters should be continuously retrieved and removed from the buffer so that incoming strings
have enough spaces to enter completely. Be sure to place a GET_BUFFER_CHAR statement in a
position to do this. Remember, Axcess is constantly running through the main program, and will
execute the GET_BUFFER_CHAR statement as long as it is in its path of execution.
To get the data of the SWT_BUFFER using REMOVE_STRING, use the following code:
IF (LENGTH_STRING(SWT_BUFFER) AND
(FIND_STRING(SWT_BUFFER,'T',1) OR FIND_STRING(SWT_BUFFER,'.',1)))
{
TRASH = REMOVE_STRING(SWT_BUFFER,'T',1)
IF (LENGTH_STRING(TRASH) = Ø)
TRASH = REMOVE_STRING(SWT_BUFFER,'.',1)
SEND_STRING Ø,"'SWT ACK',13,1Ø"
}
The code above is similar and has the same effect as the previous code. The IF condition is looking
to see if SWT_BUFFER has any characters in it with a FIND_STRING and then it looks to see if
the string contains either a 'T' or a '.', since this is the result it is looking for. Once these two
conditions are met, then we attempt to remove a 'T' from the buffer. If that attempt fails, then the
length of TRASH will be Ø. Only then will it attempt to remove the '.' since it did not find a 'T'. The
Axcess Programming Language
Using Buffers
75

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Axcess

Table of Contents