开发者

Can IDL evaluate strings as code?

开发者 https://www.devze.com 2023-01-01 16:33 出处:网络
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

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消