Dumb Dumb Question [message #13571] |
Tue, 17 November 1998 00:00  |
rosentha
Messages: 23 Registered: November 1994
|
Junior Member |
|
|
This may be really stupid, but is there a way around the following
feature:
pro x_test,x=x,x2=x2
if n_elements(x) ne 0 then print, 'x=',x
if n_elements(x2) ne 0 then print, 'x2=',x2
end
when I run it with
> x_test,x=1
I get
% Ambiguous keyword abbreviation: X.
% Execution halted at: $MAIN$
Does this mean no IDL procedure will ever work if one keyword is a left
substring of another keyword? Can I force IDL to interpret the "x" as "x"
and not an ambiguous abbreviation for "x2"?
--
Colin Rosenthal
High Altitude Observatory
Boulder, Colorado
rosentha@hao.ucar.edu
|
|
|
Re: Dumb Dumb Question [message #13608 is a reply to message #13571] |
Tue, 24 November 1998 00:00  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Colin Rosenthal wrote:
> This may be really stupid, but is there a way around the following
> feature:
>
> pro x_test,x=x,x2=x2
> if n_elements(x) ne 0 then print, 'x=',x
> if n_elements(x2) ne 0 then print, 'x2=',x2
> end
>
> when I run it with
>> x_test,x=1
> I get
> % Ambiguous keyword abbreviation: X.
> % Execution halted at: $MAIN$
>
> Does this mean no IDL procedure will ever work if one keyword is a left
> substring of another keyword? Can I force IDL to interpret the "x" as "x"
> and not an ambiguous abbreviation for "x2"?
>
Both yes:
But you can use a little trick like that:
FUNCTION is_tag,struct,tag_name
tagname=STRUPCASE(tag_name)
tags=TAG_NAMES(struct)
a=WHERE(tags EQ tagname,count)
RETURN, count
END
pro x_test,_extra=pkey
if is_tag(pkey,'x')then print, 'x=',pkey.x
if is_tag(pkey,'x2') ne 0 then print, 'x2=',pkey.x2
end
R Bauer
|
|
|