Download 5 - GE Intelligent Platforms: Support Home
Transcript
4 For numeric data, the size of the CPU data object is equal to the number of elements of the MegaBasic local variable (if it is an array variable), multiplied by the size specified by the type argument of the SYSLINK statement. A single MegaBasic integer or real variable SYSLINKed with a type argument of BOOLean would refer to a single bit in the PLC CPU. An array of 5 integers or reals SYSLINKed with type BOOLean would refer to 5 bits. An array of 16 MegaBasic integers or reals SYSLINKed with type UINT would refer to 16 contiguous 16-bit locations or 256 bits. For string data, the size of the CPU data object is equal to the maximum size of the string in bytes. MegaBasic keeps two types of size information for each string: current size and maximum size. When strings are first created, their current size and their maximum size are equal to their dimensioned size. When an assignment is made to the string, its current size changes according to the assignment that is made. However, when the string is transferred using SYSREAD or SYSWRITE, the number of bytes in its maximum size is transferred. Furthermore, whenever a string is used as a SYSREAD variable argument, its current size is set equal to its maximum size. Caution Once a MegaBasic array or string variable has been SYSLINKed, it must not be redimensioned until it is UNLINKed, or erratic behavior results. Although MegaBasic allows redimensioning, it is not a good programming practice and should be avoided. If the variable to be passed between the PLC and the PCM is a MegaBasic array variable, the type argument can be used to convert all elements of the array from one representation to another. For example, a MegaBasic program could use the type argument to convert 10 consecutive input points at %I300 to an array of ten MegaBasic integers as follows: 1000 Dim integer CPU_INPUTS ( 9 ) 1010 SYSLINK CPU_INPUTS, “%I300”, BOOL The program could now transfer the variables using the statement: 1030 SYSREAD CPU_INPUTS This sets each of the ten integers in CPU_INPUTS to 1 or 0, corresponding to the bit values of the ten CPU inputs in %I300 through %I309. GFK-0255K Chapter 4 MegaBasic 4-19