Using Buffers
75
Axcess Programming Language
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.
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
FIG. 25
Getting the next character out of a buffer with GET_BUFFER _CHAR.
Summary of Contents for Axcess
Page 1: ...instruction manual Software Axcess Programming Language ...
Page 8: ...vi Axcess Programming Language Table of Contents ...
Page 12: ...Introduction 4 Axcess Programming Language ...
Page 22: ...Axcess Basics 14 Axcess Programming Language ...
Page 38: ...Channel Characteristics 30 Axcess Programming Language ...
Page 54: ...Levels 46 Axcess Programming Language ...
Page 62: ...Operators 54 Axcess Programming Language ...
Page 66: ...Variable Types and Conversions 58 Axcess Programming Language ...
Page 70: ...Two Dimensional Arrays 62 Axcess Programming Language ...
Page 80: ...While Keywords 72 Axcess Programming Language ...
Page 86: ...Using Buffers 78 Axcess Programming Language ...
Page 94: ...Waits and Timer Keywords 86 Axcess Programming Language ...
Page 102: ...Using Subroutines 94 Axcess Programming Language ...
Page 108: ...Include Files and System_Calls 100 Axcess Programming Language ...
Page 120: ...Compiler Error Messages 112 Axcess Programming Language ...
Page 124: ...The External_Control Protocol 116 Axcess Programming Language ...