Re: input expression as a variable. [message #50620] |
Fri, 06 October 2006 13:23 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
queiny98@yahoo.com writes:
> May I read in an expression and then used it in the 'IF' or 'WHILE' or
> 'CASE'?
Not directly, no.
> For example, may I define the expression first, then use it? Or read in
> expressions from standard input or input files?
>
> expr1=' a gt 3'
>
> if(expr1) then do begin
> ******
> endif
No, but if have no objections to using EXECUTE, you could do
this in two steps:
expr1=' a gt 3'
ok = Execute('test = ' + expr1)
IF ~ok THEN RETURN
if(test) then do begin
******
endif
> May I use something like:
>
> readf, in_unit, expr1
No.
> or
>
> readf, expr1, prompt='Enter Condition:'
No.
> so, the 'expr1' can be defined more flexiable.
Be careful not to be TOO flexible. The variable you
are testing against will have to be defined in the program
module you use it in.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|