Construa um Loop

Da wiki ArcoWiki
Ir para: navegação, pesquisa

Build a Loop is the technique to repeate a sequence of instructions a certain number of times based on an initial and limit value and a specified increment.
It is important to declare all the loop variables.
The generic statement is DO/ index variable, initial value, limit value, increment.


$$ Example of a Do Loop

DECL/INTGR,i
DECL/CHAR,20,elnm
DECL/DOUBLE,xx,yy,zz


$$ This is to create some dummy points.

F(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0
F(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0
F(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0
FA(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0
FA(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0
FA(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0


$$ DO/ index variable, initial value, limit value, increment

DO/i,1,3,1
$$ commands executed during each Do cycle
elnm=ASSIGN/CONCAT('poi_',STR(i))
xx=OBTAIN/FA(@elnm),3
yy=OBTAIN/FA(@elnm),4
zz=OBTAIN/FA(@elnm),5
elnm=ASSIGN/CONCAT('newpoi_',STR(i))
F(@elnm)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
FA(@elnm)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
ENDDO