3 common functions (basic), 4 common functions (advanced), Common functions (basic) – KEYENCE SR-700 Series User Manual
Page 11: Common functions (advanced)
11
E SR SCRIPT RM
5-3
Common functions (Basic)
These functions can be used in common.
Character string processing functions
Reader status acquisition functions
*1 When the Master/Slave function is used, result data cannot be obtained correctly.
Debug function
*2 The output setting turns ON after the "SCPDBG,1" command is executed.
Function name
Argument
Return value
Applicable model
left (str, m)
str: character string
m: number of digits
(1 to 9990)
Character string of m digits
counted from the start of the
character string (str).
mid(str, s, m)
str: character string
s: 1 to 9990
m: 1 to 9990
Character string of m digits
counted from s digit position
from the start of the character
string (str). If m is not specified,
the range from the start position
(s) to the end is specified. If the
start position is outside the
range of character string data,
there is no return value.
right(str, m)
str: character string
m: 1 to 9990
Character string of m digits
counted from the end of the
character string (str)
field(str, m, sep)
str: character string
m: 1 to 9990
sep: character
(1 character)
The mth character string after
dividing the character string
(str) with the separator (sep)
Function name
Argument
Return value
Applicable model
time()
None
Time
readCount()
None
Total number of reading
results
*1
imageCount()
None
Total number of saved images
*1
result()
None
Comparison result
0: Comparison OK, 1:
Comparison NG, 2: ERROR
stable()
None
Matching level judgment result
0: STABLE, 1: UNSTABLE
ipAddress()
None
IP address (delimited by
underscore)
ex)192_168_100_001
masterSlaveID()
None
Master/Slave ID
masterSlaveGroupNa
me()
None
Master/Slave group name
Function name
Argument
Return value
Applicable model
print(str)
str: character
string
Outputs character strings (str)
when debug is executed.
*2
5-4
Common functions (Advanced)
These functions can be used in common. Following is the more advanced functions.
Numeric calculation
Character string operation
Function name
Argument
Return value
Applicable model
math.max(v,…)
v: numerical value
Maximum value among
arguments
math.min(v,…)
v: numerical value
Minimum value among
arguments
math.abs(v)
v: numerical value Absolute value
math.floor(v)
v: numerical value Integer with decimals truncated
math.ceil(v)
v: numerical value
Integer with decimals rounded
up
math.pow(a,n)
a: numerical value
n: numerical value
a
n
math.sqrt(v)
v: positive numerical value √v
math.deg(rad)
rad: numerical value
Converts radian values to angular
degrees.
math.rad(deg)
deg: numerical value
Converts angular degrees to radian
values.
math.sin(rad)
rad: numerical value sin
math.cos(rad)
rad: numerical value cos
math.tan(rad)
rad: numerical value tan
math.asin(rad)
rad: numerical value arc sin
math.acos(rad)
rad: numerical value arc cos
math.atan(rad)
rad: numerical value arc tan
Function name
Argument
Return value
Applicable model
string.len(str)
str: character string Character string (str) length
string.lower(str)
str: character string
Converts the character string
(str) to lowercase characters.
string.upper(str)
str: character string
Converts the character string
(str) to uppercase characters.
string.rep(str,n)
str: character string
n: numerical value
Character string that repeated
the character string (str) n times
string.reverse(str) str: character string
Reverses the alignment
sequence of character string
(str).
string.sub(str,i,j)
str: character string
i: numerical value
j: numerical value
Portion of character string from
ith character to jth character of
the character string (str)
string.byte(str,i)
str: character string
i: numerical value
Returns the character code for
the ith character of the
character string (str)
string.char(c1,c2,
…)
c1: numerical value
Character string for the
character code.
string.find(str,p)
str: character string
p: character string or
regular expression
Searches characters that
match p among the character
string (str), and then returns the
digit number at the head and
the digit number at the end.
string.match(str,p)
str: character string
p: character string or
regular expression
Returns characters that match
p among the character string
(str).
string.gmatch(str,
p)
str: character string
p: character string or
regular expression
Used for for loop.
Each time the characters that
match p among the character
string (str) are called, the result
is returned in turn.
string.gsub(str,p,r
,n)
str: character string
p: character string or
regular expression
r: character string
n: numerical value
(Can be omitted)
Replaces characters that match
p among the character string
(str) with r.
If n is specified, the first n
characters in the character
string are replaced.