Re: Variable name from string without EXECUTE [message #37506] |
Fri, 19 December 2003 07:48 |
Jonathan Joseph
Messages: 69 Registered: September 1998
|
Member |
|
|
I received this quick reply via email from RSI, which provides an
excellent solution. I post it here for your enjoyment.
-Jonathan
You could create an anonymous structure from your input file
name/value pairs (see CREATE_STRUCT), then pass the structure
through as an _EXTRA keyword to your target function or
procedure.
Here's a simple example
Field = 'linestyle'
value = 3
extra = create_struct(field, value)
test, _extra = extra
Pro Test, linestyle = linestyle, other = other
Plot, Findgen(10), Linestyle = linestyle
Print, 'Was other passed? ', n_elements(other) ne 0
End
You can retrieve information about allowed keywords to
user-written procedures via the /PARAMETERS keyword
to ROUTINE_INFO. (There is no equivalent for system-level
IDL routines.)
|
|
|