ISPSoft User Manual

ISPSoft User Manual ISPSoft User Manual

02.09.2014 Views

Chapter 6 Symbols • Auto-close Dialog If users unselected the Auto-close Dialog checkbox, the Add Symbol window will not be closed automatically after OK is clicked. Please refer to section 2.3.1 for more information. • Define Global If users select the Define Global checkbox, the symbol declared here will appear in the global symbol table. However, the Define Global checkbox is not in the Add Symbol window for a global symbol. 6.2.3 Using a Symbol Whose Data Type is ARRAY or STRING • Symbol whose data type is ARRAY If users want to use a symbol whose data type is ARRAY in a program, the expression format is Identifier[Index]. Generally speaking, the index is a decimal constant. If the programming language in a project for an AH500 series CPU module is a structured text, the index can be a symbol. The minimum index value must be 0, whether the index is a constant or a symbol. The maximum index value can not be larger than or equal to the number of elements in the array. For example, if the number of elements in an array is 10, the index value must be within the range between 0 and 9. If the index is a symbol, the value of the symbol can not be larger than the number of elements in the array. Otherwise, an error will occur during the operation. If users declare a symbol whose data type is ARRAY, they have to select an array type, and set the size of the array. The number of elements in an array must be within the range between 1 and 2048. A start device address is assigned to a symbol whose data type is ARRAY according to the array type. Please notice that the start device address is assigned to a symbol whose data type is ARRAY can not be an SR device, an SM device, an E device, or an F device. Please refer to section 6.1.4 for more information. Besides, an array is composed of the devices starting from the device assigned by users or the system, and the number of devices in the array conforms to the size of the array. In the figure below, ARRAY[3] OF DWOED in the Type… cell for Ary_0 indicates that the array is composed of 3 elements, and the array type is DWORD. The device address in the Address cell for Ary_0 indicates that the start device address is D0. As a result, the array is composed of D0~D5 (6 word devices). ARRAY[5] OF BOOL in the Type…cell for Ary_1 indicates that the array is composed of 5 elements, and the array type is BOOL. The device address in the Address cell for Ary_1 indicates that the start device address is M0. As a result, the array is composed of M0~M4. 6-13

ISPSoft User Manual When users declare a symbol whose data type is ARRAY, they can set the initial value of the symbol. Please refer to the following example. [1,2,3,4,5] in the Initial Value cell for A_Ary indicates that the initial value of A_Ary[0] is 1, the initial value of A_Ary[1] is 2, the initial value of A_Ary[2] is 3, the initial value of A_Ary[3] is 4, and the initial value of A_Ary[4] is 5. [1,3(0),5] in the Initial Value cell for B_Ary indicates that the initial value of B_Ary[0] is 1, the initial value of B_Ary[1] is 0, the initial value of B_Ary[2] is 0, the initial value of B_Ary[3] is 0, and the initial value of B_Ary[4] is 5. A_Ary B_Ary Element Initial value Element Initial value A_Ary[0] 1 B_Ary[0] 1 A_Ary[1] 2 B_Ary[1] 0 A_Ary[2] 3 B_Ary[2] 0 A_Ary[3] 4 B_Ary[3] 0 A_Ary[4] 5 B_Ary[4] 5 • Symbol whose data type is STRING In ISPSoft, a string is composed of ASCII codes, and the ASCII codes are surrounded by double quotes, e.g. “ABCD”. A symbol whose data type is STRING is generally used with an applied instruction. Please refer to the programming manual for a model for more information. Besides, only AH500 series CPU modules support the symbols whose data types are STRING, and the data type of a symbol of the VAR_INPUT class, the VAR_OUTPUT class, or the VAR_IN_OUT class in a function block can not be STRING. As a result, if users want to process a string in a function block, they can create the string as a global symbol. Please refer to chapter 7 for more information about the usage of function blocks. When users declare a symbol whose data type is STRING, they can specify the maximum size of the string. The number of characters in a string is within the range between 1 and 128, and one character occupies 1 byte. The number of devices assigned to the characters in a string must conform to the size of the string, and one extra byte must be assigned to the ending character in the string. If the last character and the ending character in a string does not occupy the two bytes in a word device, the ending character will be assigned another device. For example, two word devices (four bytes) will be assigned to a string which is composed of three characters, and three word devices (six bytes) will be assigned to a string which is composed of four or five characters. Please refer to the following figure. The number in the parentheses in the Type… cell for a symbol whose data type is STRING indicates the maximum size of the string. Besides, the characters in the Initial Value cell for a symbol whose data type is STRING can not be put in 6-14

<strong>ISPSoft</strong> <strong>User</strong> <strong>Manual</strong><br />

When users declare a symbol whose data type is ARRAY, they can set the initial value of the<br />

symbol. Please refer to the following example.<br />

[1,2,3,4,5] in the Initial Value cell for A_Ary indicates that the initial value of A_Ary[0] is 1, the<br />

initial value of A_Ary[1] is 2, the initial value of A_Ary[2] is 3, the initial value of A_Ary[3] is 4, and<br />

the initial value of A_Ary[4] is 5. [1,3(0),5] in the Initial Value cell for B_Ary indicates that the<br />

initial value of B_Ary[0] is 1, the initial value of B_Ary[1] is 0, the initial value of B_Ary[2] is 0, the<br />

initial value of B_Ary[3] is 0, and the initial value of B_Ary[4] is 5.<br />

A_Ary<br />

B_Ary<br />

Element Initial value Element Initial value<br />

A_Ary[0] 1 B_Ary[0] 1<br />

A_Ary[1] 2 B_Ary[1] 0<br />

A_Ary[2] 3 B_Ary[2] 0<br />

A_Ary[3] 4 B_Ary[3] 0<br />

A_Ary[4] 5 B_Ary[4] 5<br />

• Symbol whose data type is STRING<br />

In <strong>ISPSoft</strong>, a string is composed of ASCII codes, and the ASCII codes are surrounded by double<br />

quotes, e.g. “ABCD”. A symbol whose data type is STRING is generally used with an applied<br />

instruction. Please refer to the programming manual for a model for more information. Besides,<br />

only AH500 series CPU modules support the symbols whose data types are STRING, and the<br />

data type of a symbol of the VAR_INPUT class, the VAR_OUTPUT class, or the VAR_IN_OUT<br />

class in a function block can not be STRING. As a result, if users want to process a string in a<br />

function block, they can create the string as a global symbol. Please refer to chapter 7 for more<br />

information about the usage of function blocks.<br />

When users declare a symbol whose data type is STRING, they can specify the maximum size of<br />

the string. The number of characters in a string is within the range between 1 and 128, and one<br />

character occupies 1 byte. The number of devices assigned to the characters in a string must<br />

conform to the size of the string, and one extra byte must be assigned to the ending character in<br />

the string. If the last character and the ending character in a string does not occupy the two bytes<br />

in a word device, the ending character will be assigned another device. For example, two word<br />

devices (four bytes) will be assigned to a string which is composed of three characters, and three<br />

word devices (six bytes) will be assigned to a string which is composed of four or five characters.<br />

Please refer to the following figure. The number in the parentheses in the Type… cell for a<br />

symbol whose data type is STRING indicates the maximum size of the string. Besides, the<br />

characters in the Initial Value cell for a symbol whose data type is STRING can not be put in<br />

6-14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!