| rdlist (Aug2004) | rjtools | rdlist (Aug2004) |
rj> rdlist ("somefile.lis", 3)
rj> lpar rdlist
infile = "somefile.lis" file name
nline = 3 number of line to return
(cline = "a0003.fits") returned line
(ok = yes) was line read succesfully?
(mode = "ql")
2. Part of a routine with a conditional read:
for ( i = 1 ; i <= 9999 ; i += 1 ) {
rdlist ("obs010613.log", i)
if ( !rdlist.ok ) { break }
cc = substr(rdlist.cline,1,1)
if ( cc == "#" || cc == " " || cc == "" ) { break }
cparse (rdlist.cline, delim=":", nsel=1, verbose+) | scan(s1)
cparse (rdlist.cline, delim=" ", nsel=2, verbose+) | scan(s2)
cparse (rdlist.cline, delim=" ", nsel=3, verbose+) | scan(s3)
cparse (rdlist.cline, delim=" ", nsel=4, verbose-)
imcopy (s1, s2//"."//s3//cparse.cfield//"."//envget("imtype"), verbose+)
imdelete (s1, yes, verify-, default_acti+)
}
Note that a generous fixed maximum value for 'i' was used, and that the loop ends upon the first unsuccessful attempt to read a line. The result might be something like:
a0031.imh -> 0031.SKYB.fits
a0032.imh -> 0032.SKYV.fits
a0033.imh -> 0033.SKYR.fits
a0034.imh -> 0034.PG1633+099B.fits
a0035.imh -> 0035.PG1633+099V.fits
... etc.
a0195.imh -> 0195.SKYR.fits
a0196.imh -> 0196.SKYV.fits
a0197.imh -> 0197.SKYB.fits
a0198.imh -> 0198.BIAS.fits
a0199.imh -> 0199.DARK.fits