Page 1 of 1

How to loop over strings, or specific numbers

Posted: Mon Sep 22, 2008 2:58 pm
by cap
Hello,

I'd like to create a do loop where the index variable takes on the values of certain strings, or certain numbers, such as the following (which of course doesn't actually work):

--------------------------------
do i="aaa" "bbb" "ccc"

disp i

end do i
-------------------------------
or like this,
--------------------------------
do i = 2,18,23

disp i

end do i
----------------------------------




Thanks in advance,


CP

Posted: Mon Sep 22, 2008 3:17 pm
by cap
Nevermind, I got it.



declare vector[integer] myvec(3)

compute myvec(1)=7
compute myvec(2)=20
compute myvec(3)=21


dofor i=myvec
disp i
end dofor




declare string mystr

dofor mystr= "aaa" "bbb" "ccc"

disp mystr

end dofor