Global variables exist throughout the entire macro, and are available for any function in the macro. NOTE: If a
local variable has the same name as a global variable, the compiler will use the local variable in the function instead.
Global variables are global only within the macro file in which they exist. It is not
possible to share variables between different macro files. To share data between macro
files, read/write the data to share into the HMI’s Local Word (LW) and/or Local Bit
(LB) addresses using the macro’s GetData() and SetData()UM_PLC functions.
Creating Variable Arrays
Arrays are fixed-depth and 1-dimensional only. Arrays can contain up to 65,535 elements. The
type
is the
declaration of the array of elements, such as an array of
ints
, or
shorts
, or
bools
, etc. The
array_size
is the number of
elements to contain in the array, such as an array of [10] would contain 10 elements of the declared
type
. The first
register in an array always begins with the 0
th
element and the last register is the declared number of elements minus
1.
The format is:
[type] Array_Name[Array_Size]
For example:
char table[100]
The above declaration defines an array of 100 type ‘char’ registers named ‘table’. The first element in table is
address 0 and the last is 99, so it would be used as:
char FirstElement
char Last Element
FirstElement=table[0]
LastElement=table[99]
Using Macros Within Recipes
The macro utility can easily use the recipe memory area. There are 65535 recipe word registers that are available to
the user for general use (addresses RW:0 to RW:65535).
Register types: RW, RWI, and the pointer LW:9000 can be used to read or write the recipe memory area. ‘RW’
registers are used to directly address a recipe register. ‘RWI’ registers are used to indirectly address a recipe register
by using the pointer in local word memory LW:9000. If indirect addressing is used, then the direct recipe address is
determined by adding the value contained in LW:9000 to the address of the RWI register. For instance, to indirectly
point to the direct recipe address RW:20, an example would be that the macro would store the value 15 into the
LW:9000 pointer and then use an RWI address 5 (RWI:5) to GetData() or SetData() {LW:9000 = 15 + RWI:5
à
RW:20}.
The pointer has a maximum limitation of 32767, so LW:9000 can indirectly address
from an offset of 0 to 32767. To indirectly address recipe registers above 32767, you
will need to have the RWI address set to a higher address.
The macro code on the next page will clear all general-use recipe memory area. Because of the pointer’s limitation
(max of LW:9000 = 32767), it breaks up the incrementing of memory into two sections, the lower half (0 to 29999)
and upper half (30000 to 59999).
macro_command
main()
int
Address =
0
int
Initial =
0
short
Done =
0
short
Section =
1
// LW2 is used as an indicator
1010-1007, Rev 05
Mac ros
249
Summary of Contents for Silver Plus Series
Page 20: ...1010 1007 Rev 05 16 Silver Plus Series Installation Operation Manual ...
Page 31: ...COM Ports for the HMI5056 5070 1010 1007 Rev 05 Connect the OIT to the PLC or Controller 27 ...
Page 38: ...1010 1007 Rev 05 34 Silver Plus Series Installation Operation Manual ...
Page 49: ...7 Click the Shape tab 1010 1007 Rev 05 Creating Your First Project 45 ...
Page 62: ...1010 1007 Rev 05 58 Silver Plus Series Installation Operation Manual ...
Page 75: ...3 Click OK The System Parameter Settings dialog appears 1010 1007 Rev 05 Using EZware 5000 71 ...
Page 132: ...1010 1007 Rev 05 128 Silver Plus Series Installation Operation Manual ...
Page 156: ...1010 1007 Rev 05 152 Silver Plus Series Installation Operation Manual ...
Page 210: ...1010 1007 Rev 05 206 Silver Plus Series Installation Operation Manual ...
Page 216: ...1010 1007 Rev 05 212 Silver Plus Series Installation Operation Manual ...
Page 246: ...1010 1007 Rev 05 242 Silver Plus Series Installation Operation Manual ...