script error!
H.J. van Heerden wrote on Aug 20, 2007
Hi all
Have a undefined local variable error, that i can't seem to pick up. Here is a piece of the script
The code is used to rename and sort through fits files. The error is :ERROR - undefined local varieble "ffiles"
"fitlist = ffiles"
If someone could help me on this. To sort the problem I have gone as far as to rewrite the whole script. Deleted the unneseccary .par files in the uparm dir, and did a mkiraf.
I suspect that I am missing somthing small.... :(
Please help
Regards
Pat
Have a undefined local variable error, that i can't seem to pick up. Here is a piece of the script
# Sorting code to rename and sort fitfiles into lists.
procedure dirsetup (fitfiles) # Define procedure
# Define procedure variables
string fitfiles {prompt="The fitfiles to be used"}
bool filernm = yes {prompt="Rename fitfiles"}
bool sortfls = yes {prompt="Sort fitfiles"}
struct *fitlist
begin
# Define script variables
int i
bool renm, sortfiles
string ffiles, ftfls, data, fits, fitf, filter, .....
data = ""
filter = ""
# Make sure the necessary packages are loaded
if (!defpac ("imutil")){
bye()
}
;
# Check for null value for fitfiles
fitf = fitfiles
if (fitf != ""){
# Check the extn of files for non-fitfiles
i = strlen (fitf)
if ((substr (fitf, i-4, i) != ".fits") || (substr (fitf, i-3, i) != ".fit")) {
print("Warning: Incorrect filetype - Scipping file")
}
else {
# Expand the fitfiles template into a text file list
renm = filernm
if (filernm) {
rename (fitf, "fits", field="extn")
}
ffiles = mktemp ("tmp$setup")
sections (fitf, option="fullname", > ffiles)
}
}
else {
print("No fitfiles defined")
}
;
# Check if have to sort files
sortfiles = sortfls
if (sortfiles) {
# Redirect
ERROR -> fitlist = ffiles
# Create lists
....
....
# Code that is missing is just to create the different imagelists
# Scan through the fitlist
while (fscan (fitlist, fits) != EOF) {
...
...
}
;
# Code that is missing is just the sorting code into the different lists
# Clean up
fitlist = ""
delete (ffiles, ver-, >& "dev$null")
end
The code is used to rename and sort through fits files. The error is :ERROR - undefined local varieble "ffiles"
"fitlist = ffiles"
If someone could help me on this. To sort the problem I have gone as far as to rewrite the whole script. Deleted the unneseccary .par files in the uparm dir, and did a mkiraf.
I suspect that I am missing somthing small.... :(
Please help
Regards
Pat
Mike Fitzpatrick wrote on Aug 20, 2007
Hi Pat,
I don't know if it's just the code snippet you sent, but I think the error is in
The test should be '&&', otherwise this will always be true for .fits files and you'll see the warning, in which case ffiles is never set. The message basically means that the variable hasn't been set, only declared. Hope this helps.
Cheers,
-Mike
I don't know if it's just the code snippet you sent, but I think the error is in
# Check the extn of files for non-fitfiles
i = strlen (fitf)
if ((substr (fitf, i-4, i) != ".fits") || (substr (fitf, i-3, i) != ".fit")) {
print("Warning: Incorrect filetype - Scipping file")
}
The test should be '&&', otherwise this will always be true for .fits files and you'll see the warning, in which case ffiles is never set. The message basically means that the variable hasn't been set, only declared. Hope this helps.
Cheers,
-Mike
H.J. van Heerden wrote on Aug 20, 2007
Hi Mike
I think that that is it!!! :oops: Will try it tomorow when I am at the office again. Still mess up the AND - OR statements and their uses. Always had a problem with them, "When to use which one, how, ....... etc."
Thanx for the help. :wink:
I am handing in for my masters at the end of Nov. Should figure out how going to get the package to you, if you would still like to have a copy. Should be done with the final mods by then.
Enjoy!
Regards
Pat
I think that that is it!!! :oops: Will try it tomorow when I am at the office again. Still mess up the AND - OR statements and their uses. Always had a problem with them, "When to use which one, how, ....... etc."
Thanx for the help. :wink:
I am handing in for my masters at the end of Nov. Should figure out how going to get the package to you, if you would still like to have a copy. Should be done with the final mods by then.
Enjoy!
Regards
Pat
Last post on Aug 20, 2007