The Value Change operation changes the value and property of Variable, Object, and Target.
changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set,
TARGET, EXPRESSION);
3
1
2 4
1: Operation
2: Destination
3: When over
Set the operation when the value exceeds the range.
Setting in [When over]:
[Loop] does not support Real data type variables, which cause the loop to stop when the maximum value is reached.
4: Source
[Set] |
[Set]
'$Enums.AssignmentOperator.Set'
Or '=' |
Writes the variable, constant, or expression specified in the source block to the destination block. |
[AddTo] |
[AddTo] '$Enums.AssignmentOperator.AddTo'Or '+=' |
Adds the variable, constant, or expression specified in the source block to the destination block. |
[SubTo] |
[SubTo] '$Enums.AssignmentOperator.SubTo'Or '-=' |
Subtracts the variable, constant, or expression specified in the source block to the destination block. |
[MulTo] |
[MulTo] '$Enums.AssignmentOperator.MulTo'Or '*=' |
Multiplies the value of the destination block by the variable, constant, or expression specified in the source block, and copies the result to the destination block. |
[DivTo] |
[DivTo] '$Enums.AssignmentOperator.DivTo'Or '/=' |
Divides the value of the destination block by the variable, constant, or expression specified in the source block, and copies the result to the destination block. |
[AndTo] |
[AndTo] '$Enums.AssignmentOperator.AndTo'Or '&=' |
Runs the AND operation (logical product) between the integer or variable specified in the source block and the destination block, and copies the result to the destination block. |
[OrTo] |
[OrTo] '$Enums.AssignmentOperator.OrTo'Or '|=' |
Runs the OR operation (logical sum) between the integer or variable specified in the source block and the destination block, and copies the result to the destination block. |
[XorTo] |
[XorTo]
'$Enums.AssignmentOperator.XorTo'
Or '^=' |
Runs the XOR operation (exclusive logical sum) between the integer or variable specified in the source block and the destination block, and copies the result to the destination block. |
[NandTo] |
[NandTo] '$Enums.AssignmentOperator.NandTo' |
Runs the NAND operation (logical product followed by NOT) between the integer or variable specified in the source block and the destination block, then copies the result to the destination block. |
[NorTo] |
[NorTo] '$Enums.AssignmentOperator.NorTo' |
Runs the NOR operation (logical sum followed by inverter) between the integer or variable specified in the source block and the destination block, and copies the result to the destination block. |
You cannot use a negative value in a Math block and Value Change operation with mathematical operators divide (/) or modulo (%).
When you use 16 or more decimal digits in a Value Change operation (AddTo, SubTo, DivTo, MulTo), then use LINT or ULINT as the destination variable.
The [Value Change] operation allows you to set a variable or source property as the destination.
Set the value of the source block to the variable in the destination block.
(Example): Set
Operation | Destination Block | Source Block |
[Set] | Set the variable INT1 to the Variable block. | Select [Int] and set 5 to the Constant block. |
changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, INT1, 5); |
→ INT1 is set to 5 when the script is executed.
(Example): AddTo
Operation | Destination Block | Source Block |
[AddTo] | Set the variable INT1 to the Variable block. | Select [Int] and set 7 to the Constant block. |
changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.AddTo, INT1, 7); |
→ If INT1 is 3 when the script is executed, 7 of the source block is added and INT1 becomes 10.
(Example): SubTo
Operation | Destination Block | Source Block |
[SubTo] | Set the variable INT1 to the Variable block. | Select [Int] and set 3 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.SubTo, INT1, 3); |
→ If INT1 is 5 when the script is executed, the value 3 in the source block is subtracted and INT1 becomes 2.
(Example): DivTo
Operation | Destination Block | Source Block |
[DivTo] | Set the variable INT1 to the Variable block. | Select [Int] and set 2 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.DivTo, INT1, 2); |
→ If INT1 is 5 when the script is executed, its value is divided by the source block value of 2 and INT1 becomes 2. If the value is an integer type, the decimal point value is truncated.
(Example): MulTo
Operation | Destination Block | Source Block |
[MulTo] | Set the variable INT1 to the Variable block. | Select [Int] and set 5 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.MulTo, INT1, 5); |
→ If INT1 is 3 when the script is executed, its value is multiplied by the source block value of 5 and INT1 becomes 15.
(Example): AndTo
Operation | Destination Block | Source Block |
[AndTo] | Set the variable SINT1 to the Variable block. | Set the variable SINT2 to the Variable block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.AndTo, SINT1, SINT2); |
→ If SINT1 is 3 (binary: 00000011) and SINT2 is 5 (binary: 00000101), SINT1 will be 1 (binary: 00000001) when the trigger occurs.
The logical expression converts the value of the destination block and the source block to binary numbers and calculates the logical product at each digit. Set the result back to the original radix and set it to the destination block.
(Example): OrTo
Operation | Destination Block | Source Block |
[OrTo] | Set the variable SINT1 to the Variable block. | Set the variable SINT2 to the Variable block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.OrTo, SINT1, SINT2); |
→ If SINT1 is 3 (binary: 00000011) and SINT2 is 5 (binary: 00000101), SINT1 will be 7 (binary: 00000111) when the trigger occurs.
The logical expression converts the value of the destination block and the source block to binary numbers and calculates the logical sum at each digit. Set the result back to the original radix and set it to the destination block.
(Example): XorTo
Operation | Destination Block | Source Block |
[XorTo] | Set the variable SINT1 to the Variable block. | Set the variable SINT2 to the Variable block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.XorTo, SINT1, SINT2); |
→ If SINT1 is 3 (binary: 00000011) and SINT2 is 5 (binary: 00000101), SINT1 will be 6 (binary: 00000110) when the trigger occurs.
The logical expression converts the value of the destination block and the source block to binary numbers and calculates an exclusive logical sum at each digit. Set the result back to the original radix and set it to the destination block.
(Example): NandTo
Operation | Destination Block | Source Block |
[NandTo] | Set the variable SINT1 to the Variable block. | Set the variable SINT2 to the Variable block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.NandTo, SINT1, SINT2); |
→ If SINT1 is 3 (binary: 00000011) and SINT2 is 5 (binary: 00000101), SINT1 will be -2 (binary: 11111110) when the trigger occurs.
The logical expression converts the value of the destination block and the source block to binary numbers and calculates the negative logical product at each digit. Set the result back to the original radix and set it to the destination block.
(Example): NorTo
Operation | Destination Block | Source Block |
[NorTo] | Set the variable SINT1 to the Variable block. | Set the variable SINT2 to the Variable block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.NorTo, SINT1, SINT2); |
→ If SINT1 is 3 (binary: 00000011) and SINT2 is 5 (binary: 00000101), SINT1 will be -8 (binary: 11111000) when the trigger occurs.
The logical expression converts the value of the destination block and the source block to binary numbers and calculates a logical sum followed by Inverter at each digit. Set the result back to the original radix and set it to the destination block.
Set the date and time value from the source variable to the destination variable.
DATE, TIME_OF_DAY, and DATE_AND_TIME variables support the [Set] and [AddTo] operator.
The following illustrates operation behavior when the Source Block and Destination Block are DATE, TIME_OF_DAY, or DATE_AND_TIME variables:
Operation | Source Block | Destination Block | Behavior |
[Set] | DATE | DATE | Set date. |
TIME_OF_DAY | No value is set. | ||
DATE_AND_TIME | Set date only. | ||
TIME_OF_DAY | DATE | No value is set. | |
TIME_OF_DAY | Set time. | ||
DATE_AND_TIME | Set time only. | ||
DATE_AND_TIME | DATE | Set date only. | |
TIME_OF_DAY | Set time only. | ||
DATE_AND_TIME | Set date and time. | ||
[AddTo] | DATE | DATE | Add date. |
TIME_OF_DAY | No value is set. | ||
DATE_AND_TIME | Add date only. | ||
TIME_OF_DAY | DATE | No value is set. | |
TIME_OF_DAY | Add time. | ||
DATE_AND_TIME | Add time only. | ||
DATE_AND_TIME | DATE | Add date only. | |
TIME_OF_DAY | Add time only. | ||
DATE_AND_TIME | Add date and time. |
(Example): Set
Operation | Destination Block | Source Block |
[Set] | Set the variable TIME_OF_DAY1 to the Variable block. | Select [TIME_OF_DAY] and set 00:15:00 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, TIME_OF_DAY1, timeOfDay(00, 15, 00)); → When the trigger occurs, the time in TIME_OF_DAY1 is set to 00:15:00. |
If a source block is set to a [constant] date or time, any date or time value not included in the constant will be zero. For example, if you write a constant time to the DATE_AND_TIME variable, the date value will be 0 (1970/01/01).
(Example): AddTo
Operation | Destination Block | Source Block |
[AddTo] | Set the variable DATE_AND_TIME1 to the Variable block. | Select [TIME_OF_DAY] and set 00:15:00 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.AddTo, DATE_AND_TIME1, timeOfDay(00, 15, 00)); |
→ If DATE_AND_TIME1 is 2024/10/01 12:34:56, when the trigger occurs, 00:15:00 in the source block is added and DATE_AND_TIME1 becomes 2024/10/01 12:49:56.
A single bit of data is set to the destination variable.
(Example): Set
Operation | Destination Block | Source Block |
[Set] | Set the variable BOOL1 to the Variable block. | Select [Int] and set 1 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, BOOL1, 1); |
→ BOOL1 is set to ON when the trigger occurs.
A string is set to the destination variable.
(Example): Set
Operation | Destination Block | Source Block |
[Set] | Set the variable STRING1 to the Variable block. | Select [STRING] and set "DEF" to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, STRING1, "DEF"); |
→ STRING1 is set to DEF when the trigger occurs.
(Example): AddTo
Operation | Destination Block | Source Block |
[AddTo] | Set the variable STRING1 to the Variable block. | Select [STRING] and set "DEF" to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.AddTo, STRING1, "DEF"); |
→ If STRING1 is "AB", when the trigger occurs, "DEF" is added to the source block and STRING1 becomes "ABDEF".
Set the value in the source block to the source property in the destination block.
(Example 1)
Operation | Destination Block | Source Block |
[Set] | Set the object source property Rectangle1.Thickness to the Object block. | Select [Int] and set 10 to the Constant block. |
changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $GraphicObject.Rectangle1.Thickness, 10); |
→ The Rectangle1 border thickness changes to 10 when the trigger occurs.
(Example 2)
Operation | Destination Block | Source Block |
[Set] | Set the object source property Lamp1.Interlock to the Object block. | Select [Int] and set 0 to the Constant block. |
changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $GraphicObject.Lamp1.Interlock, 0); |
→ Lamp1 interlock state is set to OFF when the trigger occurs.
Set the value in the source block to the source property in the destination block.
(Example)
Operation | Destination Block |
Source Block |
[Set] | Set the variable source property INT1.Value to the Variable block. | Select [Int]
and set 1 to the Constant block.
|
changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, INT1.Value, 1); |
→ INT1.Value is set to 1 when the trigger occurs.
Set the value in the source block to the source property in the destination block.
(Example 1)
Set a date for the Target.
Operation | Destination Block | Source Block |
[Set] | Set target source property Target01.DateAndTime.Date to the Target block. | Select [Date] and set 10/17/2017 to the Constant block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Date, date(2017, 10, 17)); |
→ Display unit is set to 10/17/2017 when the trigger occurs.
(Example 2)
Set the date and time of the display unit to the same date and time as the external device.
(Example 2-1)
Set the date and time (year, month, day, hours, minutes, seconds) of the external device to integer variables INT1 to INT6, respectively.
Operation | Destination Block | Source Block |
[Set] | Set the target source property to the Target block. Target01.DateAndTime.Year Target01.DateAndTime.Month Target01.DateAndTime.Day Target01.DateAndTime.Hour Target01.DateAndTime.Minute Target01.DateAndTime.Second |
Set the variable INT1 to INT6 to the Variable block. |
![]() onScheduledDay(23, 0, () => { changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Year, INT1.Value); changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Month, INT2.Value); changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Day, INT3.Value); changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Hour, INT4.Value); changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Minute, INT5.Value); changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.Second, INT6.Value); }); |
→ The date and time on the display unit are set to the date and time of the external device at 23:00 every day.
(Example 2-2)
Set the date and time of the external device to a DATE_AND_TIME variable Var1 as the number of seconds (32-bit integer) from 1970/01/01 00:00:00 UTC. For the relationship between the value of Var1 and the date and time, refer to the following.
TIME, DATE, TIME_OF_DAY, DATE_AND_TIME
Operation | Destination Block | Source Block |
[Set] | Set the target source property Target01.DateAndTime.DateTime to the Target block. | Set the variable Var1 to the variable block. |
![]() onScheduledDay(23, 0, () => { changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.DateAndTime.DateTime, Var1.Value); }); |
→ The date and time on the display unit are set to the date and time of the external device at 23:00 every day.
(Example 3)
Turn off the backlight of the display unit.
Operation | Destination Block | Source Block |
[Set] | Set the target source property Target01.Preferences.BacklightOff to the Target block. | Set the variable BOOL1 with value 1 in the Variable block. |
![]() changeValue($Enums.WhenOver.Loop, $Enums.AssignmentOperator.Set, $Target.Target01.Preferences.BacklightOff, BOOL1.Value); |
→ The display unit's backlight turns off when the trigger occurs.