
Include Files and System_Calls
98
Axcess Programming Language
DEFINE_VARIABLE
NUM1
NUM2
DEFINE_PROGRAM
NUM1 = 5
NUM2 = 6
SYSTEM_CALL 'SQUARE' (NUM1)
SYSTEM_CALL 'SQUARE' (NUM2)
This code generates two calls to the subroutine SQUARE in the library file, but it only includes and
compiles the library file once. The two SYSTEM_CALLs call the same routine. This is acceptable
for most SYSTEM_CALLs, but there are occasions where this could cause problems, as shown in
the following example. In this example, make a new library file that has WAIT statements in its
subroutine. Here is a listing:
DEFINE_CALL 'SEND' (CARD,STR1[1Ø],STR2[1Ø])
{
SEND_STRING CARD, STR1
WAIT 2Ø 'SS WAIT'
SEND_STRING CARD, STR2
}
This subroutine takes three parameters. The purpose of the subroutine is to send the two strings to
the device specified in the parameter variable CARD, with a delay of 2 seconds between sends.
The following line will send the string 'AMX', followed 2 seconds later by the string 'Axcess' to
SWT, defined as card 3:
SYSTEM_CALL 'SEND' (SWT1,'AMX','Axcess')
This code compiles and works fine. The following code and related paragraphs describe the effect
of adding another SYSTEM_CALL to the program:
SYSTEM_CALL 'SEND' (SWT1,'AMX','Axcess')
SYSTEM_CALL 'SEND' (SWT2,'GOOD','TIMES')
In this case, only one DEFINE_CALL SEND is compiled, and both of these lines call the same
subroutine. The first call sets the routine's STR1, STR2, and CARD parameter variables, sends the
string 'AMX' to device SWT1, and starts the named WAIT. The next SYSTEM_CALL resets the
parameter variables to all new values, and sends the string 'GOOD' to card SWT2. However, since
the WAIT is already in the wait list, the second WAIT is ignored. When the WAIT comes due, it
will use the latest values stored in the parameter variables CARD and STR2. In this case, CARD
will still be SWT2, and STR2 will contain the string 'TIMES', so 'TIMES' is sent to device number
SWT2.
The string 'Axcess' is never sent to card SWT1. This is because the STR2 parameter variable in the
subroutine is overwritten by the second SYSTEM_CALL before the WAIT comes due. This is the
problem with using WAITS in SYSTEM_CALL subroutines. The solution is to use an instance
number to force the compiler to compile two separate copies of the subroutine. Here is an example
of the same SYSTEM_CALLs using instance numbers:
SYSTEM_CALL [1] 'SEND' (SWT1,'AMX','Axcess')
SYSTEM_CALL [2] 'SEND' (SWT2,'GOOD','TIMES')
Содержание Axcess
Страница 1: ...instruction manual Software Axcess Programming Language ...
Страница 8: ...vi Axcess Programming Language Table of Contents ...
Страница 12: ...Introduction 4 Axcess Programming Language ...
Страница 22: ...Axcess Basics 14 Axcess Programming Language ...
Страница 38: ...Channel Characteristics 30 Axcess Programming Language ...
Страница 54: ...Levels 46 Axcess Programming Language ...
Страница 62: ...Operators 54 Axcess Programming Language ...
Страница 66: ...Variable Types and Conversions 58 Axcess Programming Language ...
Страница 70: ...Two Dimensional Arrays 62 Axcess Programming Language ...
Страница 80: ...While Keywords 72 Axcess Programming Language ...
Страница 86: ...Using Buffers 78 Axcess Programming Language ...
Страница 94: ...Waits and Timer Keywords 86 Axcess Programming Language ...
Страница 102: ...Using Subroutines 94 Axcess Programming Language ...
Страница 108: ...Include Files and System_Calls 100 Axcess Programming Language ...
Страница 120: ...Compiler Error Messages 112 Axcess Programming Language ...
Страница 124: ...The External_Control Protocol 116 Axcess Programming Language ...
Страница 143: ...Index 135 Axcess Programming Language ...