comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » passing strings as arguments?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
passing strings as arguments? [message #25227] Mon, 04 June 2001 13:54 Go to next message
noymer is currently offline  noymer
Messages: 65
Registered: June 1999
Member
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

GOOGLE: you don't own this messgae I posted it with GNUS ha ha
Re: passing strings as arguments? [message #25362 is a reply to message #25227] Tue, 05 June 2001 07:37 Go to previous messageGo to next message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
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.

The following method exploits the fact that /keyword and keyword=1 are
equivalent:

;- Define keyword defaults
circle = 0
box = 0
triangle = 0

;- Set keyword values according to shape string
case shape of
'circle' : circle = 1
'box' : box = 1
'triangle' : triangle = 1
else : message, 'Shape string not recognized'
endcase

;- Create plot
plot, x, y, psym=plotsym(scale=2, /fill, $
circle=circle, box=box, triangle=triangle)

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley/
Re: passing strings as arguments? [message #25374 is a reply to message #25227] Mon, 04 June 2001 14:17 Go to previous messageGo to next message
mperrin+news is currently offline  mperrin+news
Messages: 81
Registered: May 2001
Member
noymer@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.

Well, right. The argument "/circle" is just shorthand for "circle=1", which
(a) is a numerical not a string parameter and (b) is part of the interpreted
code rather than data. So you can't just pass in a string.

The easiest way to do this is probably with the "execute" command:

IF (condition) THEN myshape=string('/circle') ELSE
myshape=string('/triangle')
ENDIF

commandstr = "plot,x,y,psym=plotsym("+myshape+",scale=2,/fill)"
result = execute(commandstr)

Alternatively, you could do something like:

IF (condition) THEN mytriangle=1 ELSE
mycircle=1
ENDIF

plot,x,y,psym=plotsym(circle=mycircle, triangle=mytriangle,scale=2,/fill)

But that's a bit uglier and scales less well to multiple arguments.

- Marshall
Re: passing strings as arguments? [message #25421 is a reply to message #25227] Thu, 07 June 2001 12:25 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
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
>
> GOOGLE: you don't own this messgae I posted it with GNUS ha ha

Here is one of our plot symbol routines.
It accepts numbers as well as strings.

http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/icgsym_n.tar.gz

For further routines and licensing please have a look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml


try:

x=findgen(10)
y=sin(x)
icgsym_n,'circle'
plot,x,y,psym=8


with icgsym_n,/symhelp you get a list of numbers and names

e.g. 218 is a half filled circle

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 Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL 5.4 and MacOS 9.1
Next Topic: Re: I paid for my new boat with this

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:43:42 PDT 2025

Total time taken to generate the page: 0.00619 seconds