diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/digiphot/apphot/aputil/apgscur.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'noao/digiphot/apphot/aputil/apgscur.x')
-rw-r--r-- | noao/digiphot/apphot/aputil/apgscur.x | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/noao/digiphot/apphot/aputil/apgscur.x b/noao/digiphot/apphot/aputil/apgscur.x new file mode 100644 index 00000000..5cc8a6df --- /dev/null +++ b/noao/digiphot/apphot/aputil/apgscur.x @@ -0,0 +1,88 @@ +include <gset.h> +include <fset.h> + +# APGSCUR -- Read the x and y coordinates of an object from a file and move +# the cursor to those coordinates. + +int procedure apgscur (sl, gd, xcur, ycur, prev_num, req_num, num) + +int sl # coordinate file descriptor +pointer gd # pointer to graphics stream +real xcur, ycur # x cur and y cur +int prev_num # previous number +int req_num # requested number +int num # list number + +int stdin, nskip, ncount +pointer sp, fname +int fscan(), nscan(), strncmp() +errchk greactivate, gdeactivate, gscur + +begin + if (sl == NULL) + return (EOF) + + call smark (sp) + call salloc (fname, SZ_FNAME, TY_CHAR) + + # Find the number of objects to be skipped. + call fstats (sl, F_FILENAME, Memc[fname], SZ_FNAME) + if (strncmp ("STDIN", Memc[fname], 5) == 0) { + stdin = YES + nskip = 1 + } else { + stdin = NO + if (req_num <= prev_num) { + call seek (sl, BOF) + nskip = req_num + } else + nskip = req_num - prev_num + } + + # Initialize. + ncount = 0 + num = prev_num + + # Read the coordinates and write the cursor. + repeat { + + # Print the prompt if file is STDIN. + if (stdin == YES) { + call printf ("Type object x and y coordinates: ") + call flush (STDOUT) + } + + # Fetch the coordinates. + if (fscan (sl) != EOF) { + call gargr (xcur) + call gargr (ycur) + if (nscan () == 2) { + ncount = ncount + 1 + num = num + 1 + } + } else + ncount = EOF + + # Move the cursor. + if (gd != NULL && (ncount == nskip || ncount == EOF)) { + iferr { + call greactivate (gd, 0) + call gscur (gd, xcur, ycur) + call gdeactivate (gd, 0) + } then + ; + } + + } until (ncount == EOF || ncount == nskip) + + call sfree (sp) + + if (ncount == EOF) { + return (EOF) + } else if (nskip == req_num) { + num = ncount + return (ncount) + } else { + return (num) + } +end |