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

Home » Public Forums » archive » Re: printing variable and variable name
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
Re: printing variable and variable name [message #67660] Tue, 18 August 2009 09:06
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Aug 18, 11:39 am, Daniel Bruynooghe
<daniel.bruynoo...@googlemail.com> wrote:
> Hi guys,
>
> I wanted to write a tiny procedure which prints a variable name and
> the value and a newline, the c  equivalent would be a macro along the
> lines -  #define PRINT_DOUBLE(x) printf(#x "= %f\n", x)
> but I don't know how to overcome pass - by - value.
>
> Ideal functionality:
>
> testVar = 1
> my_print, testVar
>
> testVar = 10
> IDL>
>
> Any suggestions?
>
> Many thanks,
>
> Daniel

This should work - even though it doesn't look
very pretty when it's called with a value instead
of a variable :)

PRO my_print,x

print,scope_varname(x,level=-1)+' = '+string(x)

END


IDL> q=2
IDL> my_print,q
Q = 2


Ciao,
Paolo
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: printing variable and variable name
Next Topic: xml

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

Current Time: Fri Oct 10 13:40:29 PDT 2025

Total time taken to generate the page: 1.03339 seconds