Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi,
I have specified Set x=3+4; in script and when i evaluate as =$(x) in text box, it gives 7.Why is that so ?
The different engines involved act like that because of two simple reasons:
A SET statement assigns the right hand part as-is to the variable specified in the left hand part. So x will contain string '3+4'.
Now in the expression, the evaluator will perform $-sign substitution first, before doing anything else. That gets the original expression =$(x) converted into =3+4 after which the expression is finally evaluated and produces a fixed value of 7. That one gets displayed.
Note that what applies to the expression with respect to $-sign substitution always coming first, also applies to the right-hand part of the SET statement. $-sign substitution in the right-hand part of a SET statement will be applied even before the scripting engine tries to figure out what statement it is looking at. And that's the main reason why stuff like the following even works at all !
SET y = SET;
$(y) x = 3+4;
If this explanation is unclear, please ask away.
Best,
Peter
It seems to be correct to me, what do you see as wrong?
What do you expect to see?
What is your required output?
Off course, Because you are computing using $() indicator. Remove that and check with simple x ??
Set x=3+4; //vVar has the expression 2+3 as value we have to compute it using $(vVar) which returns 5
Let x=3+4; //vVar has the computed value 5
The different engines involved act like that because of two simple reasons:
A SET statement assigns the right hand part as-is to the variable specified in the left hand part. So x will contain string '3+4'.
Now in the expression, the evaluator will perform $-sign substitution first, before doing anything else. That gets the original expression =$(x) converted into =3+4 after which the expression is finally evaluated and produces a fixed value of 7. That one gets displayed.
Note that what applies to the expression with respect to $-sign substitution always coming first, also applies to the right-hand part of the SET statement. $-sign substitution in the right-hand part of a SET statement will be applied even before the scripting engine tries to figure out what statement it is looking at. And that's the main reason why stuff like the following even works at all !
SET y = SET;
$(y) x = 3+4;
If this explanation is unclear, please ask away.
Best,
Peter