Re: passing strings as arguments? [message #25225] |
Mon, 04 June 2001 14:17  |
ronn
Messages: 123 Registered: April 1999
|
Senior Member |
|
|
in article yx6h3d9gufti.fsf@socrates.Berkeley.EDU,
noymer@socrates.Berkeley.EDU at noymer@socrates.Berkeley.EDU wrote on 6/4/01
4:54 PM:
> I am using Ronn Kling's PLOTSYM, the usage of which is:
>
> plot,x,y,psym=plotsym(/circle,scale=2,/fill)
>
> instead of /circle, one could use /box, /triangle, etc...
>
> I have something like:
>
> IF (condition) THEN myshape=string('/circle') ELSE
> myshape=string('/triangle')
> ENDIF
>
> and I want to pass the string "myshape" to plotsym as the
> first argument but I can't figure out how to do this in IDL 5.3.
>
> It seems not to like strings being passed there.
Hi Andrew,
Plotsym is looking for keywords so passing a string isn't going to work. But
you can use the _extra keyword instead. What you want to do is create an
anonymous structure that contains the keywords. Here's how
IF (condition) THEN myshape={circle:1} ELSE
myshape={triangle:1}
ENDIF
plot,x,y,psym=plotsym(_extra=myshape,scale=2,/fill)
You can also put the scale and fill keywords in myshape also. Just remember
that something like /fill has to be fill : 1 in the structure.
Ronn Kling
--
Ronn Kling
KRS, inc.
email: ronn@rlkling.com
"Application Development with IDL"� programming book updated for IDL5.4!
"Calling C from IDL, Using DLM's to extend your IDL code" NEW BOOK!
Shareware and Freeware at: http://www.rlkling.com/
|
|
|
Re: passing strings as arguments? [message #25226 is a reply to message #25225] |
Mon, 04 June 2001 14:13   |
mchinand
Messages: 66 Registered: September 1996
|
Member |
|
|
In article <yx6h3d9gufti.fsf@socrates.Berkeley.EDU>,
<noymer@socrates.Berkeley.EDU> wrote:
> I am using Ronn Kling's PLOTSYM, the usage of which is:
>
> plot,x,y,psym=plotsym(/circle,scale=2,/fill)
>
> instead of /circle, one could use /box, /triangle, etc...
>
> I have something like:
>
> IF (condition) THEN myshape=string('/circle') ELSE
> myshape=string('/triangle')
> ENDIF
>
> and I want to pass the string "myshape" to plotsym as the
> first argument but I can't figure out how to do this in IDL 5.3.
>
> It seems not to like strings being passed there.
>
> TIA,
> Andrew
You could use the EXECUTE function. Something like
result=EXECUTE('plot,x,y,psym=plotsym('+myshape+',scale=2,/f ill)')
Hope that helps,
--Mike
--
--
Michael Chinander University of Chicago
m-chinander@uchicago.edu (773)834-5101 (Voice) (773)702-0371 (Fax)
|
|
|
Re: passing strings as arguments? [message #25365 is a reply to message #25225] |
Mon, 04 June 2001 23:39   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
ronn kling wrote:
>
> in article yx6h3d9gufti.fsf@socrates.Berkeley.EDU,
> noymer@socrates.Berkeley.EDU at noymer@socrates.Berkeley.EDU wrote on 6/4/01
> 4:54 PM:
>
>> I am using Ronn Kling's PLOTSYM, the usage of which is:
>>
>> plot,x,y,psym=plotsym(/circle,scale=2,/fill)
>>
>> instead of /circle, one could use /box, /triangle, etc...
>>
>> I have something like:
>>
>> IF (condition) THEN myshape=string('/circle') ELSE
>> myshape=string('/triangle')
>> ENDIF
>>
>> and I want to pass the string "myshape" to plotsym as the
>> first argument but I can't figure out how to do this in IDL 5.3.
>>
>> It seems not to like strings being passed there.
> Hi Andrew,
>
> Plotsym is looking for keywords so passing a string isn't going to work. But
> you can use the _extra keyword instead. What you want to do is create an
> anonymous structure that contains the keywords. Here's how
>
> IF (condition) THEN myshape={circle:1} ELSE
> myshape={triangle:1}
> ENDIF
>
> plot,x,y,psym=plotsym(_extra=myshape,scale=2,/fill)
>
> You can also put the scale and fill keywords in myshape also. Just remember
> that something like /fill has to be fill : 1 in the structure.
>
> Ronn Kling
Dear Ronn,
If he is using create_struct to create the anonymous structure
he is able to use his string argument.
IF (condition) THEN myshape=create_struct(string_argument,1) ELSE $
myshape={triangle:1}
plot,x,y,psym=plotsym(_extra=myshape,scale=2,/fill)
cheers
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum J�lich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
|
|
|
Re: passing strings as arguments? [message #25366 is a reply to message #25226] |
Mon, 04 June 2001 23:41  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Mike Chinander wrote:
>
> In article <yx6h3d9gufti.fsf@socrates.Berkeley.EDU>,
> <noymer@socrates.Berkeley.EDU> wrote:
>> I am using Ronn Kling's PLOTSYM, the usage of which is:
>>
>> plot,x,y,psym=plotsym(/circle,scale=2,/fill)
>>
>> instead of /circle, one could use /box, /triangle, etc...
>>
>> I have something like:
>>
>> IF (condition) THEN myshape=string('/circle') ELSE
>> myshape=string('/triangle')
>> ENDIF
>>
>> and I want to pass the string "myshape" to plotsym as the
>> first argument but I can't figure out how to do this in IDL 5.3.
>>
>> It seems not to like strings being passed there.
>>
>> TIA,
>> Andrew
>
> You could use the EXECUTE function. Something like
>
> result=EXECUTE('plot,x,y,psym=plotsym('+myshape+',scale=2,/f ill)')
>
> Hope that helps,
Remember if you are using the EXECUTE you are not able
to run the code by runtime.
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum J�lich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
|
|
|