# Meaning of double :=

Hi,
I have a statement like this, does it add var1 and var2 in var_tot ?
or var_tot will be equal to var1 and var2 ?

var_tot := var1 := var2

As you can see I’m new in Natural

Hi Pierre
This is simply a way of initializing multiple values with the value furthest to the right
Try running the example program below to see the result
There are multiple other more intuitive ways to do this.

1. if the value is zero/blank use RESET
2. if the value is not just zero - say 10 - you can set an init value in the definition and then use RESET INITIAL
… and probably many more

Finn

``````define data local
1 var1 (I2) init <5>
1 var2 (I2)
1 var_tot (I2)
end-define
var1 := 5
var2 := 10
var_tot := 1
var_tot := var1 := var2 /* initialize all variables with var2
display var_tot var1 var2
reset initial var1
write 'Var1 after reset' var1

END
``````
1 Like

Just to be clear: if you want to sum var1 and var2 and put the result in var_tot, you can use any of these statements:

``````VAR_TOT := VAR1 + VAR2
COMPUTE VAR_TOT = VAR1 + VAR2
``````