@for

HelloI need your help

How can call the field name of a screen.

For example my fields are :

test1

test2

test3

The programme don’t find the field “test1” with the formula “test”&i why ???

How to compose the field name dependind of the variable i???

@For( i:=1;i<=22; i:=i + 1;

@If (“test”&i >15;@SetField(“Test”&i;“O”);“”));

Thanks for your help

Atawalpa Yupanki

Subject: @for

One suggestion I am not 100% sure it will work, is use + sign instead of & sign.

e.g. part of one of my (working) formulas is here:

Temp :=

@If(Product1=“”;“1”;

@If(Product2=“”;“2”;

@If(Product3=“”;“3”;

@If(Product4=“”;“4”;

@If(Product5=“”;“5”;

@If(Product6=“”;“6”;

@If(Product7=“”;“7”;

@If(Product8=“”;“8”;

@If(Product9=“”;“9”;Product)))))))));

FIELD Hide := Hide;

FIELD Hide1 := Hide1;

FIELD Hide2 := Hide2;

FIELD Hide3 := Hide3;

FIELD Hide4 := Hide4;

FIELD Hide5 := Hide5;

FIELD Hide6 := Hide6;

FIELD Hide7 := Hide7;

FIELD Hide8 := Hide8;

FIELD Hide9 := Hide9;

FIELD Count := Count;

@Command([RefreshHideFormulas]);

@If(Product9=“”;

@Do(

@Command([RefreshHideFormulas]);

@SetField(“Hide” + Temp;“Yes”);

@Command([RefreshHideFormulas]);

@SetField(“Remove” + Temp;“No”);

@SetField(“Count”; Count + 1);

etc

Subject: @for

The inside part of your @for loop doesn’t look right.

You have:

@If (“test”&i >15;@SetField(“Test”&i;“O”);“”));

but the first test is comparing a string and a number. Perhaps you mean

@If (i >15;@SetField(“Test”&i;“O”);“”));

but that still wouldn’t change test1, since you are testing for greater than 15, so maybe your loop should say:

@For( i:=1;i<=22; i:=i + 1;

@SetField(“Test”&i;“O”));

Update: See for further good points about using ‘+’ instead of ‘&’ and @Text to turn a number to text. I forgot to mention those.

Subject: @for

The problem is in the condition of your @If statement.Firstly, in the Formula language, the ampersand operator “&” is a logical AND, not a concatenator. Two strings can be concatenated with a plus sign, but your i variable is a number, so you’d have to use @Text on it first.

Secondly, Notes needs to know that you want to test the value of a field called TEST1 otherwise it will compare the literal “test1” with the number 15. Apart from this not being your intention, it will produce another string/number type mismatch problem.

Thirdly, you’re testing the field values against a number (15), then setting them to a text value in the next bit. So are the Test fields text or numbers? For the purposes of demonstration, I’ll assume they contain numbers and that you want to reset them to 0 (zero) if they contain a value greater than 15.

So you probably need something like…

@For( i:=1;i<=22; i:=i + 1;

tmpFieldVal := @GetField (“test” + @Text(i));

@If (tmpFieldVal > 15; @SetField(“Test”&i;0);“”)

);

Subject: surpised that ben did not see that… LOL

@For( i:=1;i<=22; i:=i + 1;tmpFieldVal := @GetField (“test” + @Text(i));

@If (tmpFieldVal > 15; @SetField(“Test” + @Text(i);0);“”)

);

ian

Subject: *Yup, too sleepy this morning. Sorry.

Subject: RE: *Yup, too sleepy this morning. Sorry.

Ben, time for holiday!

JYR

Subject: RE: *Yup, too sleepy this morning. Sorry.

Almost Christmas…(dear Santa, i need new users, new customers, new laptopS, a new brain, but I’ll keep my wike, ok ?)

I need some too… before I say to an AllBlacks player to go F O… I feel a lil bit angry against nothing at this time…

:wink:

have a nice evening you both, it’s merely time to go home.

ian

Subject: RE: @for

Thanks for your help. It 's ok.You are the best !!!

Atawalpa