icnt (Aug2004) rjtools icnt (Aug2004)

icnt

## NAME

icnt - loop counter tool

icnt

## DESCRIPTION

Simple task to keep track of counters (e.g., in nested loops within IRAF CL macros, or in command line applications). Per call, one counter may be updated. Default is to increase the counter that was updated in the previous call, but it may be explicitly set by specifying parameter 'ni'. If 'ireset' (or 'dreset') is true, all counters (increments) are reset to their default values. Also, the default counter is then reset to 1. Using 'i1max' and 'i2max' nested while-loops can be created, with 'i1' the innermost counter. If you want to be sure that the counters will be in the specified range and starting from the minimum values, initialize 'i1', 'i2', and 'i3' to 'i1min - d1', 'i2min - d2', and 'i3min - d3'.

## EXAMPLES

Exerpt from a CL macro that inserts a set of 2-D spectra into a larger mosaic at regular intervals in x and y:

```    iwc ("spectra.lis")
print (122*(1+int((iwc.nlines-1)/29.)) | scan(j)
icnt(ireset=yes, dreset=yes)
for ( i = 1 ; i < iwc.nlines ; i = i + 1 ) {
if ( i == 1 ) {
icnt(ni=1, i1=0, i2=-15, i3=2, d1=1, d2=17, d3=122, i1min=0,
i2min==2, i3min=2, i1max=512, i2max=495, i3max=j)
} else {
icnt (ni=1)
icnt (ni=2)
}
rdlist("spectra.lis", icnt.i1)
chkimg(rdlist.cline, "access", imtype="", verbose-)
printf("[%s:%s,%s:%s]\n",icnt.i3,icnt.i3+119,icnt.i2,icnt.i2+14) |\
scan (s1)
imcopy(rdlist.cline, "mosaic"//chkimg.imtype//s1, verbose-)
}
```