Compare_String; Constant; Create_Buffer - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Keywords & Run-Time Library Functions (Cont.)

COMPARE_STRING

CONSTANT

CREATE_BUFFER

NetLinx Programming Language Reference Guide
This keyword compares two character strings. If either string contains a '?' char-
acter, the matching character in the other string is not compared. The '?' is
equivalent to a wilcard. For example:
DEFINE_LIBRARY_FUNCTION LONG COMPARE_STRING(CHAR A[],
CHAR B[])
Here is some useful debugging code:
tstStr = 'ALEXERICRYAN'
ulError = COMPARE_STRING ( tstStr, 'ALEX' )
if( ulError == 0 )
SEND_STRING dvDebug, 'ALEXERICRYAN != ALEX'
else
SEND_STRING dvDebug, 'ALEXERICRYAN == ALEX... BAD!'
tstStr = 'ALEXERICRYAN'
ulError = COMPARE_STRING ( tstStr, 'ALEXERICRYAN' )
if ( ulError == 0 )
SEND_STRING dvDebug, 'ALEXERICRYAN !=
ALEXERICRYAN...BAD!'
else
SEND_STRING dvDebug, 'ALEXERICRYAN == ALEXERICRYAN'
tstStr = 'ALEXERICRYAN'
ulError = COMPARE_STRING ( tstStr, 'ALEX????RYAN' )
if ( ulError == 0 )
SEND_STRING dvDebug, 'ALEXERICRYAN !=
ALEX????RYAN...BAD!'
else
SEND_STRING dvDebug, 'ALEXERICRYAN == ALEX????RYAN
Another example of a use for this feature is if you want an event to occur every
hour. You would enter a time string that would contain a '??;00 ;00' (hours/
minute/sec) for the recurring event that in this case would occur every hour.
Result: The returned result can only be True (1) or False (0).
• 0 = the strings don't match
• 1 = the strings are the same
This keyword is used as part of a variable declaration to specify that the variable
cannot be changed at run-time. If a variable is declared with this keyword, it
must be initialized in its declaration.
This keyword creates a buffer and can only appear in the DEFINE_START
section of the program.
CREATE_BUFFER DEV, Buffer
CREATE_BUFFER directs NetLinx to place any strings received from the speci-
fied device into the specified buffer (character array). When strings are added
to the buffer, the length of the buffer is automatically adjusted. If the buffer is
full, all bytes in the buffer are shifted to make room for the new string. A buffer
can be manipulated in the same way as a character array.
Reserved Identifiers
109

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents