11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FOR (legacy version)Incrementing with Argumentless FORThe argumentless FOR operates the same as the FOR variable=start:increment form. Theonly difference is that it does not provide a way to keep track of the number of loop executions.Two (or more) spaces are required after the FOR keyword in an argumentless FOR command.The following example shows how the previous loop counter example might be rewrittenusing the argumentless FOR. The assignment i=i+1 replaces the loop counter. Note the twospaces following the argumentless FOR keyword.Average2loopSET sum=0SET i=0FOR READ !,"Number: ",num QUIT:num="" SET sum=sum+num,i=i+1SET average=sum/iWRITE !!,"Average is: ",averageQUITNotesFOR and WatchpointsYou have limited use of watchpoints with FOR. If you establish a watchpoint for the control(index) variable of a FOR command, <strong>Caché</strong> triggers the specific watchpoint action only onthe initial evaluation of each FOR command argument. This restriction is motivated by performanceconsiderations.The following example contains three kinds of FOR command arguments for the watchedvariable X: a range, with initial value, increment, and limit (final value); a single value; anda range with initial value, increment, and no limit. Breaks occur when X has the initial values1, 20, and 50.USER>ZBREAK *XUSER>FOR X=1:1:10,20,50:2 SET T=X QUIT:X>69USER 2f0>wX=1USER 2f0>gUSER>FOR X=1:1:10,20,50:2 SET T=X QUIT:X>69USER 2f0>wT=10X=20USER> 2f0>gUSER>FOR X=1:1:10,20,50:2 SET T=X QUIT:X>69USER 2f0>wT=20X=50USER 2f0>gUSER>wT=70X=70<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 751

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!