Strange behaviour in procedure script?
Gabriel wrote on Mar 11, 2009
Hi,
I'm writing a procedure script that looks like this:
procedure test1 (query parameters)
#declaration of parameters
real fwhm {prompt = "Ingrese el valor de FWHM"}
begin
#declaration of variables
string variable1
#if structure
if (xxxxx) {
xxxx
xxx
}
else {
xxx
}
etc... (more script commands)
end
The thing is that when I run this script, it FIRST runs the 'if structure' and THEN it asks for the 'query parameters' (defined before 'begin').
Am I doing something wrong? Is this the way it should work?
In any case I want it to do this (I'm happy with the way the script runs), I just don't know if this is a sign that something is not working properly (in that case I'd rather fix it now that the script is small) or just normal behaviour.
Thanks!
I'm writing a procedure script that looks like this:
procedure test1 (query parameters)
#declaration of parameters
real fwhm {prompt = "Ingrese el valor de FWHM"}
begin
#declaration of variables
string variable1
#if structure
if (xxxxx) {
xxxx
xxx
}
else {
xxx
}
etc... (more script commands)
end
The thing is that when I run this script, it FIRST runs the 'if structure' and THEN it asks for the 'query parameters' (defined before 'begin').
Am I doing something wrong? Is this the way it should work?
In any case I want it to do this (I'm happy with the way the script runs), I just don't know if this is a sign that something is not working properly (in that case I'd rather fix it now that the script is small) or just normal behaviour.
Thanks!
Mike Fitzpatrick wrote on Mar 11, 2009
The query is made when the parameter is first accessed in the script, if this is after your 'if' statement then that would explain it. A common practice is to first get all the parameters at the top of your script and save them to local variables, this will avoid the query each time the parameter is accessed (i.e. a query parameter in a loop may prompt each time).
-Mike
-Mike
Gabriel wrote on Mar 11, 2009
Thanks Mike, now I get why it's doing this.
Since the 'if structure' is a control (a "check point"), I want it to appear before the query parameters (if this check is 'no', the script must exit).
Since the 'if structure' is a control (a "check point"), I want it to appear before the query parameters (if this check is 'no', the script must exit).
Last post on Mar 11, 2009