3 - 5 3 - 5
3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS
3.2.3 Array and structure
In ST programs, arrays and structures can be used as data.
Arrays and structures are data having a structure that can be handled as one block in a
program when their elements are defined with local or global labels before use.
(1) Array
An array is a data type that has been defined by combining multiple data of the
same type.
For an array in an ST program, each element can be referred to individually by
specifying its element number within [ ] after the variable (label) name defined for
the array type.
The specification numbers of the array elements are counted from 0.
[Format]
Array name[specification number of array element]
[Image diagram]
When a word type array having four elements is set to have the array name of
Unit price, the specification numbers of the array elements are 0, 1, 2, 3.
100
1200
1300
800
Unit price[0] Unit price[1] Unit price[2] Unit price[3]
For a word type array, word data enters each array element.
[Description example]
Unit price [0] := 100; (* 100 is assigned to the first element of the array *)
(* 1200 is assigned to the second element of the array using device D1 *)
Data type INT can be used as
the specification number of the
array element.
D1 := 1;
Unit price[D1] := 1200;
(*Unit price [0] + Unit price [1] is assigned to the third element of the array *)
Unit price [2] := Unit price [0] + Unit price [1];
pen1 := 3;
Unit price[pen1] := 800;
A label can be used as the
specification number of the
array element.
Содержание MELSEC L series
Страница 1: ...Programming Manual Structured Text ...
Страница 2: ......
Страница 73: ...4 33 4 33 4 ST PROGRAM EXPRESSIONS MEMO ...
Страница 297: ......