ihave two fields field a one valuefieldb 2nd value
field c contains the following code
x:=fielda;
y:=fieldb;
z=x-y;
r=z+x;
@if(x=y;@setfield(“a”;“2”);@setfield(“a”;z))
r=z=x here i m getting error; how to rectify this
ihave two fields field a one valuefieldb 2nd value
field c contains the following code
x:=fielda;
y:=fieldb;
z=x-y;
r=z+x;
@if(x=y;@setfield(“a”;“2”);@setfield(“a”;z))
r=z=x here i m getting error; how to rectify this
Subject: how to add two numbers
You’re missing your colon on r := z + z
You code says:
@if(x=y;@setfield(“a”;“2”);@setfield(“a”;z))
In one case you’re setting to the text value “2” and in the other case you’re trying to set it to a number. Notes can be forgiving but are fields “a”, “fielda” and “fieldb” text fields or numbers?
You also need to watch out for no value set.
You could change your code to something like (I am assuming they are all text fields):
r := 0;
x := 0;
y := 0;
z := 0;
x := @if( @Trim(FieldA)=“”; 0; @isNumber(FieldA); @TextToNumer(FieldA); 0);
y := @if( @Trim(FieldB)=“”; 0; @isNumber(FieldB); @TextToNumer(FieldB); 0);
z := x-y;
r := z+x;
@if(x=y;@setfield(“a”;“2”);@setfield(“a”;@Text(z) ))
Subject: RE: how to add two numbers
Using @ToNumber instead of @TextToNumber, you should be able to even get rid of the @If statements.