Script Ver1 (SC1 syntax)

<< Click to Display Table of Contents >>

Manual > Scripting Guide >

Script Ver1 (SC1 syntax)

What is SC1 syntax?

This chapter explains the syntax of Script Ver1 (hereafter referred to as SC1).

 

The SC1 syntax is intended to allow easy use of simple calculations, and is a simple script for performing calculations between tags using Visual Basic compatible operators such as + - * / < >.

 

Since processing is executed one line at a time, you cannot use if statements (conditional branching) or for statements (repeated processing). If you want to perform more advanced processing, please use Script Ver2 (SC2 syntax).

 

 

SC1 can be used from the following:

 

FA-Server "Script Ver1 Action"

FA-Server Script execution on the detailed settings tab of each action

 

 

 

hint

In version 4 of this package, it was called tag script, but in Ver5 and later, the name was changed to Script Ver1 (abbreviated as SC1 syntax) in order to streamline the script syntax system.

 

 

Basic Syntax

The SC1 syntax is written as follows:

 

Tag path 1 = Calculation expression 1

Tag path 2 = Expression 2

Tag path 3 = Expression 3

 

When the script is executed, the result of the formula is written to the tag. The formula can contain a tag path. If you want to write multiple formulas, write them on separate lines. All calculations are done numerically, with "TRUE" being treated as 1 and "FALSE" being treated as 0, and characters being converted to numbers.

 

example)

U01.F01.T01 = 1
U01.F01.T01 = U01.F01.T02 * (U01.F01.T03 + 1)
U01.F01.T01 = (U01.F01.T02 And U01.F01.T03) Or (U01.F01.T04 And U01.F01.T05)

 

hint

SC1 syntax cannot handle characters. For character type tags, characters are converted to numbers and processed. If you want to handle values as characters, for example to combine strings, please use Script Ver2 (SC2 syntax).

 

 

Operators

The available operators are summarized below.

 

Operator

Arithmetic Operators

 

Exponentiation

^

Calculates the power of a number.

Minus sign

-

Used to specify the negated value of an expression.

Multiplication

*

Calculates the product of two numbers.

division

/

Calculates the quotient of two numbers.

Integer division

\

Calculates the quotient of two numbers and returns the result as an integer.

Modulus operation

Mod

Divides two numbers and returns the remainder.

Add

+

Calculates the sum of two numbers.

Subtract

-

Finds the difference between two numbers.

 

Comparison Operators

 

equal

=

Compares two numbers and returns TRUE if they are equal.

Not equal

<>

Compares two numbers and returns TRUE if they are not equal.

Less than

<

Compares two numbers and returns TRUE if the left value is less than the right value.

Greater than

>

Compares two numbers and returns TRUE if the left value is greater than the right value.

below

<=

Compares two numbers and returns TRUE if the left value is less than or equal to the right value.

End

>=

Compares two numbers and returns TRUE if the left value is greater than or equal to the right value.

 

Logical Operators

 

Logical negation

Not

Returns the logical negation of an expression.

Logical AND

And

Performs a logical AND on two expressions.

Logical OR

Or

Performs a logical disjunction on two expressions.

Exclusive OR

Xor

Performs a logical exclusive OR on two expressions.

Logical Equality

Eqv

Performs a logical equality operation on two expressions.

Logical implication

Imp

Performs a logical implication on two expressions.

Logical AND

AndN

Performs a logical AND on two expressions (bit-wise comparison as numeric values).

Logical OR

OrN

Performs a logical OR on two expressions (bit-wise comparison as numeric values).

 

 

Calculation example

Arithmetic Operators

 


 

example

result

Exponentiation

^

2 ^ 3

8

Minus sign

-

3 – 2

1

Multiplication

*

2 * 1.5

3

division

/

5 / 2

2.5

Integer division

\

15 \ 2

7

Modulus operation

Mod

15 Mod 2

1 (15 / 2 = 7 with a remainder of 1)

Add

+

1 + 0.5

1.5

Subtract

-

twenty four

-2

 

Comparison Operators

 


 

example

result

equal

=

12 = 12

1


 

34 = 12

0

Not equal

<>

12 <> 12

0


 

34 <> 12

1

Less than

<

12 < 12

0


 

12 < 34

1

Greater than

>

12 > 12

0


 

34 > 12

1

below

<=

12 <= 12

1


 

34 <= 12

0

End

>=

12 >= 12

1


 

12 >= 34

0

 

Logical Operators

 


 

example

result

Logical negation

Not

Not 1

0


 

Not 0

1


 

Not 123

0

Logical AND

And

1 And 1

1


 

1 And 0

0


 

0 And 1

0


 

0 And 0

0


 

12 And 123

1

Logical OR

Or

1 Or 1

1


 

1 Or 0

1


 

0 Or 1

1


 

0 Or 0

0


 

12 Or 123

1

Exclusive OR

Xor

1 Xor 1

0


 

1 Xor 0

1


 

0 Xor 1

1


 

0 Xor 0

0


 

12 Xor 123

0

Logical Equality

Eqv

1 Eqv 1

1


 

1 Eqv 0

0


 

0 Eqv 1

0


 

0 Eqv 0

1


 

12 Eqv 123

1

Logical implication

Imp

1 Imp 1

1


 

1 Imp 0

0


 

0 Imp 1

1


 

0 Imp 0

1


 

12 Imp 123

1

Logical AND

AndN

1 AndN 1

1


 

1 AndN 0

0


 

0 AndN 1

0


 

0 AndN 0

0


 

12 AndN 123

8(00001100 AndN 01111011 = 00001000)

Logical OR

OrN

1 OrN 1

1


 

1 OrN 0

1


 

0 OrN 1

1


 

0 OrN 0

0


 

12 OrN 123

127(00001100 OrN 01111011 = 01111111)

 

 

 

attention

When multiple operators are used in an expression, they are evaluated in a certain order. Arithmetic operators are evaluated first, followed by comparison operators, and then logical operators. Arithmetic and logical operators are evaluated in the order shown in the table above. All comparison operators have the same precedence. You can force a different precedence order by using parentheses "()". Operations inside parentheses always take precedence over operations outside parentheses.

 

hint

When using Network tag in a script, add "//Network/" Please add.

 

example)

//Network/N01/T01