Welcome to iraf.net Saturday, May 11 2024 @ 06:53 PM GMT


 Forum Index > Help Desk > Systems New Topic Post Reply
 while (fscan) - problem
   
FSBoyden
 03/03/2008 12:33PM (Read 2663 times)  
++++-
Regular Member

Status: offline


Registered: 06/07/2006
Posts: 95
Hi allBack 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.[code:1:1b445de1ae]
# 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")

}
;
[/code:1:1b445de1ae]
And here is an example of the output.
[quote:1b445de1ae]
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 :
[/quote:1b445de1ae]
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

 
Profile Email
 Quote
fitz
 03/03/2008 12:33PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
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[code:1:9e8180e712]imglist = ""[/code:1:9e8180e712]and before the inner while loop 'open' the file anew wth e.g.[code:1:9e8180e712]imglist = "myfile"[/code:1:9e8180e712]
Cheers,
-Mike

 
Profile Email
 Quote
   
Content generated in: 0.08 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login