|
Re: functions arguments [message #46380 is a reply to message #46379] |
Tue, 15 November 2005 02:22  |
Timm Weitkamp
Messages: 66 Registered: August 2002
|
Member |
|
|
Liberum wrote:
> Hi everyone,
>
> I have a function that takes several arguments and one keyword.
>
> whenever I try to use one of the arguments in a Keyword_set() function
> or Case IDL says that the variable is undefined. I am missing something
> here and I don't know what.
> ------------------------------------------------------------ ------------------------------------------------------------ ---------------
> function tool, cp, date, til, VERBOSE=verbose
>
> if keyword_set(verbose) then print, format='(%"The product selected is
> %s for %s")', cp, date
>
> CASE cp OF
> c4 : extract = "Ma"
> c8 : extract = "CT"
> ch : extract = "HGT"
> ENDCASE
> ------------------------------------------------------------ ------------------------------------------------------------ -----------------
> This variation also fails:
> **************************************************
> function tool, cp, date, til, VERBOSE=verbose
>
> CASE cp OF
> c4 : extract = "Ma"
> c8 : extract = "CT"
> ch : extract = "HGT"
> ENDCASE
> **************************************************
>
> IDL call results:
> a = tool(c4,200412,D,/verbose)
> % PRINT: Variable is undefined: CP.
>
> Appreciate any help rendered,
> Lib
In the calling sequence "a = tool(c4,200412,D,/verbose)", the
expression "c4" is a variable, and this variable is apparently not
defined. This is what causes the error.
Did you intend "c4", "c8", and "ch" to be string values? In that case,
all occurrences of the string value must be put in quotes (single or
double), both in the function call and in the CASE expression.
Hope this helps,
Timm
Timm Weitkamp, ESRF, Grenoble, France
|
|
|