beautypg.com

3 table, Definition of table, 4 array – KEYENCE SR-700 Series User Manual

Page 5: Definition of array, Table, Array, Format

background image

5

E SR SCRIPT RM

2-3

Table

The table is the data configuration to collect multiple data.

Definition of table

The table can store multiple data (fields).
Fields can store numerical values and character string data as variables do.

„

Declaration of table

Format

„

Reference to data within the table

Table name.field name

local

“table name” ={field 1, field 2, field 3}

Example 1) Table declaration and initialization

local

Product ={ LotNo=123 , Serial No=1001 , name="camera"}

Declares table Product.
LotNo=123
Serial No =1001
name ="camera"

Example 2) Reference to data variables within the table

local a = 0

Declares variable a.

local

Product ={ LotNo=123 , Serial No=1001 , name="camera"}

Declares table Product.

a = Product.name

Stores the name field of
the table Product in a.

123

LotNo

1001

SerialNo

“camera”

name

Product

Table

Data (fields) such as LotNo, SerialNo and name are collected in the table (Product).

2-4

Array

The array is a type of table and a data column that can store multiple values.
Similar to normal variables, reference and assignment can be made.

Definition of array

Values such as numerical values, character strings or calculated results can be
assigned to arrays.

„

Naming rules for array

Array names must start with a 1-byte alphanumeric character for the first character.
For the second character and after, 1-byte alphanumeric characters and "_"
(underscore) can be used. Array elements start from [1].

„

Declaration of array

Format

„

Assignment and initialization of array variable

Assign values to array valuables using { } and values. Specify multiple values by
dividing "," (comma).

local

“arrayname” ={}

Example

local

b ={}

Declares array b.

Example

local

a={}

Declares array a.

a = {3,4,5,6}

Assigns the 4 values 3, 4, 5, and 6 to array a.

local

b ={16,51,55}

Declares array b and initializes it with the 3
values 16, 51, 55.

local

b[3] = 10

Assigns 10 to the third value of array b.

local

b[4] = 11

Assigns 11 to the fourth value of array b (adds 1
element).

3

b[1]

4

b[2]

5

b[3]

6

b[4]

7

b[5]

b

Table

Numerical values 3,4,5,6,7 are stored in table b.

This manual is related to the following products: