Array And Structure - Mitsubishi Electric MELSEC Q Series Programming Manual

Structured text
Hide thumbs Also See for MELSEC Q Series:
Table of Contents

Advertisement

3 HANDLING OF CHARACTERS AND NUMERIC VALUES IN ST PROGRAMS

3.2.3 Array and structure

3 - 5
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.
Unit price[0] Unit price[1] Unit price[2] Unit price[3]
100
For a word type array, word data enters each array element.
[Description example]
Unit price [0] := 100;
(* 1200 is assigned to the second element of the array using device D1 *)
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;
1200
1300
(* 100 is assigned to the first element of the array *)
Data type INT can be used as
the specification number of the
array element.
A label can be used as the
specification number of the
array element.
800
3 - 5

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melsec l series

Table of Contents