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
Thanks in advance !
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
Thanks in advance !
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.
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
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
ADD VAR1 VAR2 GIVING VAR_TOT
COMPUTE VAR_TOT = VAR1 + VAR2
And Finn has already addressed what the multiple assignment statement does.
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 ?
Hi,
If I understood the statement from the original post correctly, it should do the following:
First var1 is set to value of var2.
After that, var_tot will be set to the value of var1, which is equal to value of var2 in this case.
Regards,
Holger