views:

52

answers:

1

Is there any functionality in IDL that will allow it to evaluate a a string as code?

Or, failing that, is there a nice, dynamic way of including /KEYWORD in functions? For example, if I wanted to ask them for what type of map projection the user wants, is there a way to do it nicely, without large if/case statements for the /Projection_Type keyword it needs?

With even a small number of user options, the combinations would cause if/case statements to get out of hand very quickly to handle all the possible options.

A: 

The best bet is to use a case statement because you can't trust that your user is going to type in the same string for Projection_Type that you're expecting as in the keyword.

Though if you are set on doing something like this, there is the EXECUTE function that treats a string as an IDL statement:

Result = EXECUTE(String [, QuietCompile] [, QuietExecution])

Edited to add, there's also CALL_FUNCTION and CALL_PROCEDURE that are faster but maybe less flexible. Look them all up in the IDL help and see what works for you.

miked