smp |
04/21/2009 08:19AM (Read 4219 times)
|
|
|
Status: offline
Registered: 07/27/2008
Posts: 70
|
Hi,If I run the following script, I get the error message:[quote:60df9fc34d]ERROR on line 16: FXF: number is not a decimal
mean ()[/quote:60df9fc34d]Script is:[code:1:60df9fc34d]procedure mean (input)string input
int max_linesbegin file means_left
int i for(i=1;i<=max_lines;i=i+1)
{
imstat(input//"[1:60,i:i]",fields="mean",format=no) | scan(means_left)
}end
[/code:1:60df9fc34d]please tell what is going wrong?
Thanks
|
|
|
|
fitz |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
You need to construct the image section so it is a valid string, e.g.[code:1:a82ea93eb0]imstat (input//"[1:60,"//i//":"//i//"]", fields="mean", .....[/code:1:a82ea93eb0]This concatenates the image name with some literal strings and the 'i' variable to create the image section. -Mike
|
|
|
|
smp |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 07/27/2008
Posts: 70
|
Thanks Mike.
It helped.Now I have following doubts:
(1) Regarding this
[code:1:3bff713850]imstat(input_copy//"[1:60,"//i//":"//i//"]",.....[/code:1:3bff713850]is there any rule for when to use slashes (//) and when to use double quotes(") ?(2) In following segment:[code:1:3bff713850]imstat(input_copy//"[1:60,"//i//":"//i//"]",fields="mean",format=no) | scan(x)
print (x,>"means_left")
[/code:1:3bff713850]I get the error:
[quote:3bff713850]ERROR on line 27: cannot open `means_left' for writing[/quote:3bff713850]But if I use >> operation, I do not get the error. I suppose that >> is meant for appending the new thing to previously existing thing.(3) If I use following statement instead :[code:1:3bff713850]imstat(input_copy//"[1:60,"//i//":"//i//"]",fields="mean",format=no) | scan("means_left")
[/code:1:3bff713850]I do not get any error, but the file "means_left" is not created.Regards
smp
|
|
|
|
fitz |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
[quote:6fa9879799]
(1) Regarding this
Code:
imstat(input_copy//"[1:60,"//i//":"//i//"]",.....
is there any rule for when to use slashes (//) and when to use double quotes(") ?
[/quote:6fa9879799]Literal strings must be in double quotes, the '//' operator simply concatenates strings. In this example, 'input_copy' is a string variable and 'i' is an int variable, but the 'i' variable is converted internally so the entire operation is one big set of string concatenations.[quote:6fa9879799]
ERROR on line 27: cannot open `means_left' for writing[/quote:6fa9879799]By default, IRAF won't let you overwrite an existing file. The '>>' is a file append, if you want to overwrite you need to either explicitly delete the file first, or else do a [code:1:6fa9879799]cl> set clobber = yes[/code:1:6fa9879799]where the 'clobber' environment variable says to let you overwrite.As for the last example, a scan() to a literal string can't be done, the first two answers should be all you need.-Mike
[/quote]
|
|
|
|
fitz |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
[quote:6e217161fe]
(1) Regarding this
Code:
imstat(input_copy//"[1:60,"//i//":"//i//"]",.....
is there any rule for when to use slashes (//) and when to use double quotes(") ?
[/quote:6e217161fe]Literal strings must be in double quotes, the '//' operator simply concatenates strings. In this example, 'input_copy' is a string variable and 'i' is an int variable, but the 'i' variable is converted internally so the entire operation is one big set of string concatenations.[quote:6e217161fe]
ERROR on line 27: cannot open `means_left' for writing[/quote:6e217161fe]By default, IRAF won't let you overwrite an existing file. The '>>' is a file append, if you want to overwrite you need to either explicitly delete the file first, or else do a [code:1:6e217161fe]cl> set clobber = yes[/code:1:6e217161fe]where the 'clobber' environment variable says to let you overwrite.As for the last example, a scan() to a literal string can't be done, the first two answers should be all you need.-Mike
|
|
|
|
smp |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 07/27/2008
Posts: 70
|
when I say[code:1:f75a5d3261]file means_left
int i[/code:1:f75a5d3261]Is it not that meas_left is a variable of data type file, as i is a variable of data type integer.I mean, can't I save different file names in this variable - means_left - if it is one?
|
|
|
|
fitz |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
[quote:cffe6abfdc]I mean, can't I save different file names in this variable - means_left - if it is one?[/quote:cffe6abfdc]Yes. A 'file' type is effectively a string variable, but you need to use it as a variable, i.e. do not put it in quotes so the value of the variable is used and not the literal string "means_left".-Mike
|
|
|
|
smp |
04/21/2009 08:19AM
|
|
|
Status: offline
Registered: 07/27/2008
Posts: 70
|
thanksRegards
smp
|
|
|
|