Loop with different variables
Posted: July 19th, 2018, 3:26 pm
Hi, I'm trying to write a loop that simplifies the following:
I have tried a solution like this:
But it doesn't work. I would appreciate any suggestions. I didn't define S1P08A as a single item with multiple occurences because S1P08A is already in a roster with multiple occurences.
Code: Select all
if pos("A", S1P08) <> 0 then
S1P08A_1 = 1;
else
S1P08A_1 = 0;
endif;
if pos("B", S1P08) <> 0 then
S1P08A_2 = 1;
else
S1P08A_2 = 0;
endif;
if pos("C", S1P08) <> 0 then
S1P08A_3 = 1;
else
S1P08A_3 = 0;
endif;
Code: Select all
numeric i;
string alphabet = "ABCDEFGH";
do i = 1 while i <= 8
string letter = alphabet[i:1];
if pos(letter, S1P08) <> 0 then
S1P08A_i = 1;
else
S1P08A_i = 0;
endif;
enddo;