User guide

4
E SR SCRIPT RM
2-1 Naming rules
This describes naming rules for variables, etc. used in the script.
Naming methods
Script file name
The script file name handled by SR-1000/D100/750/700 is FmtSet.lua only.
Names defined in the script program
Types of Name defined in the script program are as follows.
Variable name, array variable name
Function name
Definitions of variable name and table name
Start the name with a 1-byte alphanumeric character.
1-byte alphanumeric characters and "_" (underscore) can be used.
Do not use reserved words.
For reserved words, "8-2 Reserved words/Language elements" (Page 18).
2-2 Variables
Character strings and numerical values used in the script are stored in containers
called variables to be handled.
Definition of variable
Values such as numerical values, character strings or calculated results can be
assigned to variables.
Declaration of variable
Format
Assignment and initialization of variable
Storing a value in a variable is called "assignment".
Assigning a value at the time of variable declaration is called "Initialization".
If this is referred with no value assigned to the variable, an error will occur when
executing the script.
NOTICE
Do not use "_" (underscore) at the beginning of the name.
It may not operate normally.
local "variable name"
Example
local a Declares variable a.
Example
local a=0 Initializes with 0 when declaring variable a.
a=1 Assigns 1 to variable a.
3
a
Variable name
Stores numerical value 3 in variable a.
Characters and numerical values that can be assigned to variables
3 types of values can be assigned to variables: character string, numerical value
and logical value
* The condition that no value is assigned to the variable is called nil. If it is referred,
an error will occur. Be sure to assign a value before referring to the variable.
character string
z Text notation
Expresses with the text surrounded with "". Numerical values, symbols and
character strings can be written in "".
z Character code (decimal number) notation
Expresses the character string by specifying the ASCII code decimal number after
¥.
z Escape sequence
Expresses control characters and symbols using escape characters (¥).
Numerical value
z Positive and negative integer (decimal number notation)
This expresses positive integer and negative integer as decimal number.
z Positive and negative decimal (decimal number notation)
This expresses positive decimal and negative decimal as decimal number.
Important
Decimal uses double-precision floating-point number, which may
have a margin of error.
z Hexadecimal number notation
This expresses 0 or positive integer by adding a hexadecimal number after 0x.
The hexadecimal number notation cannot express decimal and negative integer.
Logical value
Logical value shows True or False to processed results.
Escape sequence
character string
Text notation : "ABC", "keyence"
Character code (decimal number) notation : "¥013¥010"
([CR][LF])
Escape sequence : "¥r"
(CR)
Numerical value
Integer number : 1, -1
Decimal number : 2.0, -2.0
Hexadecimal number notation : 0x0a
Logical value
True : true
False : false
Example
a = "ABC" Assigns character string "ABC" to variable a.
b = "¥013¥010"
Assigns character code (decimal number)
notation "¥013¥010"([CR][LF]) to variable b.
c = ¥r
Specifies line break (¥r) to variable c with escape
sequence.
Example
a= 123
Assigns decimal number integer 123 to variable a.
b = -1.5
Assigns decimal number integer -1.5 to variable b.
c = 0x0f Assigns hexadecimal number f to variable c.
Pattern Meaning
¥r [CR](0x0D)
¥n [LF](0x0A)
¥a [BEL](0x07)
¥b [BS](0x08)
¥f [CL](0x0c)
¥t [HT](0x09)
¥v [VT](0x1B)
¥¥ Yen si gn
¥" Double quotation
¥' Single quotation
¥000 Specifies an arbitrary character code as decimal number.