Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

While loop: counter in the field name

Avatar

Avatar
Validate 1
Level 1
dherberger
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
dherberger
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
dherberger
Level 1

03-09-2013

Here is the code I have. I have tested it and it works on the one number field. (in Formcalc)

if ((FS270Pt1 >= 28.5) and (FS270Pt1 <= 38))

then FS270Pt1.font.fill.color.value = "0,0,0"

else FS270Pt1.font.fill.color.value = "255,0,0"

endif

I have 15 number fields that I need to apply this color font to should the criteria be met.  I am trying to use a While statement to achieve this.  From what I know I have deduced that it would look something like this:

var i = 1

while (i <= 15)

do

     if ((FS270Pt(i) >= 28.5) and (FS270Pt(i) <= 38))

          then FS270Pt(i).font.color.value = "0,0,0"

          else FS270Pt(i).font.color.value = "255,0,0"

     endif

     i = i + 1

endwhile

When I run the 'Check Script Syntax' I do not get any errors.  However, at runtime it states that FS270Pt is unknown.  How can I perform a loop on the binding names of the fields?

View Entire Topic

Avatar

Avatar
Validate 10
Level 4
Bibhu_Bikash_Na
Level 4

Likes

37 likes

Total Posts

630 posts

Correct Reply

46 solutions
Top badges earned
Validate 10
Validate 1
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Validate 10
Level 4
Bibhu_Bikash_Na
Level 4

Likes

37 likes

Total Posts

630 posts

Correct Reply

46 solutions
Top badges earned
Validate 10
Validate 1
Give Back 10
Give Back 5
Give Back 3
View profile
Bibhu_Bikash_Na
Level 4

03-09-2013

It will throw error. Because the instances of the field that you are referencing is not correct. You need to loop through the instances of the field. The field name is FS270Pt1. So it's instances witll be FS270Pt1[0], FS270Pt1[1], FS270Pt1[2] ..etc.

So inyour code replace

FS270Pt(i) with FS270Pt1[" + i + "]. It should work.

Thanks,

Bibhu.