while (fscan) - problem
H.J. van Heerden wrote on Mar 03, 2008
Hi all
Back with the programming Q's :wink:
For the standard star solutions the mknobsfile task needs a file formatted with the star-names and their associated files.
I am trying to put together a short script that creates that file. Here is the core code.
And here is an example of the output.
As can be seen the script creates the correct format only for the first star, there-after it doesn't seem to enter the second while loop??
Logically it should work, unless I am making a mistake in my handling of the "while (fscan)" procedure.
P.S. What is the maximum string length that can be printed, because when I am trying to print all the associated files next to the star name, "print" gives me an error message?
Thanx
Pat
Back with the programming Q's :wink:
For the standard star solutions the mknobsfile task needs a file formatted with the star-names and their associated files.
I am trying to put together a short script that creates that file. Here is the core code.
# Scan through the strlist
while (fscan (strlist, star) != EOF) {
starfile = ""
# Scan through the imglist
while (fscan (imglist, img) != EOF) {
# Get variable values
k = strlen(star)
# Greate file string
if (star == substr(img, 1, k)) {
starfile = starfile + " " + img
}
;
}
;
print (star, " : ", starfile, >> "standstars")
}
;
And here is an example of the output.
E803 : E803_012_B.fits E803_012_I.fits E803_012_R.fits E803_012_U.fits E803_012_V.fits
E804 :
E809 :
E815 :
E816 :
E817 :
E836 :
E837 :
E846 :
E853 :
As can be seen the script creates the correct format only for the first star, there-after it doesn't seem to enter the second while loop??
Logically it should work, unless I am making a mistake in my handling of the "while (fscan)" procedure.
P.S. What is the maximum string length that can be printed, because when I am trying to print all the associated files next to the star name, "print" gives me an error message?
Thanx
Pat
Mike Fitzpatrick wrote on Mar 03, 2008
After the first run, the 'imglist' pointer is at the end of the file and remains there. What you need to do is effectively close the file using the command
and before the inner while loop 'open' the file anew wth e.g.
Cheers,
-Mike
imglist = ""and before the inner while loop 'open' the file anew wth e.g.
imglist = "myfile"Cheers,
-Mike
Last post on Mar 03, 2008