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

Home » Public Forums » archive » Re: Defining constants in IDL?
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: Defining constants in IDL? [message #31233] Thu, 27 June 2002 15:51 Go to next message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
I believe that the @ statement also works in PVWave. However, you have to be
careful with @. You can't have any leading spaces, or spaces between it and
the filename. So, you should change "@ junk" to "@junk", and make sure that
the @ is all the way over to the left.

William Thompson


jeyadev@wrc.xerox.bounceback.com (Surendar Jeyadev) writes:

> In article <B93A247B.5660%ronn@rlkling.com>,
> ronn kling <ronn@rlkling.com> wrote:
>>
>> Hi Marshall,
>>
>> Actually there is something similiar to including a header file. What you
>> need is a file with no header (i.e. pro or function as the first line) and
>> no end statement. For example,
>>
>> a = 0
>> True = 1
>> False = 0
>> yes = 'YES'
>>
>> could be saved in a file called constants.pro.
>>
>> To include this in your own code you would do this.
>>
>> pro myProcedure, p1, p2
>>
>> @constants
>>
>> ...
>> ...
>>
>> end
>>
>> The @ sign acts as an include statement to the compiler.

> Alas, it fails with PV-Wave. Does anyone have a workaround?

> kaveri 193% cat junk.pro
> a = 1.0
> b = 2.0
> c = 3.0

> kaveri 194% cat try.pro

> pro try, x

> @ junk
> print, x + a
> print, x + b
> print, x + c

> end
>
> .....
> .....

> WAVE> .run try
> % Input line is too long for input buffer of 511 characters.
> % Compiled module: TRY.
> WAVE>

> Not good, eh? Thought it was my file try.pro that was the problem.
> Turns out that it is not. Commenting the line out makes the file
> 'compile'.

> I must say that the lack of this facility in very irksome. It is
> one of the great adavantages of Python, which, though similar to
> IDL/Wave has distinct advantages with namespaces, etc. There are
> many times that I would like to call a Wave "main" programme
> from another (just as I would Unix scripts) and not being able
> means doing some of the work with Python, etc.



> --

> Surendar Jeyadev jeyadev@wrc.xerox.bounceback.com
>
> Remove 'bounceback' for email address
Re: Defining constants in IDL? [message #31263 is a reply to message #31233] Tue, 25 June 2002 10:37 Go to previous messageGo to next message
jeyadev is currently offline  jeyadev
Messages: 78
Registered: February 1995
Member
In article <B93A247B.5660%ronn@rlkling.com>,
ronn kling <ronn@rlkling.com> wrote:
>
> Hi Marshall,
>
> Actually there is something similiar to including a header file. What you
> need is a file with no header (i.e. pro or function as the first line) and
> no end statement. For example,
>
> a = 0
> True = 1
> False = 0
> yes = 'YES'
>
> could be saved in a file called constants.pro.
>
> To include this in your own code you would do this.
>
> pro myProcedure, p1, p2
>
> @constants
>
> ...
> ...
>
> end
>
> The @ sign acts as an include statement to the compiler.

Alas, it fails with PV-Wave. Does anyone have a workaround?

kaveri 193% cat junk.pro
a = 1.0
b = 2.0
c = 3.0

kaveri 194% cat try.pro

pro try, x

@ junk
print, x + a
print, x + b
print, x + c

end

.....
.....

WAVE> .run try
% Input line is too long for input buffer of 511 characters.
% Compiled module: TRY.
WAVE>

Not good, eh? Thought it was my file try.pro that was the problem.
Turns out that it is not. Commenting the line out makes the file
'compile'.

I must say that the lack of this facility in very irksome. It is
one of the great adavantages of Python, which, though similar to
IDL/Wave has distinct advantages with namespaces, etc. There are
many times that I would like to call a Wave "main" programme
from another (just as I would Unix scripts) and not being able
means doing some of the work with Python, etc.



--

Surendar Jeyadev jeyadev@wrc.xerox.bounceback.com

Remove 'bounceback' for email address
Re: Defining constants in IDL? [message #31306 is a reply to message #31263] Mon, 24 June 2002 06:43 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Bob wrote:
>
> I have a quick question. I am a big newbie when it comes to IDL, but
> the place that I work at uses it extensively. I am used to C/C++, and
> I want to know how does one define a constant in IDL (similar to
> #DEFINE TRUE 1 in C/C++). I have read through the user manuals, but to
> no avail. Also, are there any good tutorials online to help a
> struggling newbie like me? The user manuals 'cover' all the material,
> but rather poorly.

Dear Bob

there was a while ago someone else who likes to know something like
this.

The whole thread on google you'll find:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&a mp;frame=right&th=a988307b311ea495&seekm=3BB9E19F.BB 8321E5%40fz-juelich.de#link1


Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
Re: Defining constants in IDL? [message #31307 is a reply to message #31306] Mon, 24 June 2002 06:04 Go to previous messageGo to next message
Robert Stockwell is currently offline  Robert Stockwell
Messages: 74
Registered: October 2001
Member
Bob wrote:

> I have a quick question. I am a big newbie when it comes to IDL, but
> the place that I work at uses it extensively. I am used to C/C++, and
> I want to know how does one define a constant in IDL (similar to
> #DEFINE TRUE 1 in C/C++). I have read through the user manuals, but to
> no avail. Also, are there any good tutorials online to help a
> struggling newbie like me? The user manuals 'cover' all the material,
> but rather poorly.
>


in your startup file, you can define system variables

DEFSYSV, '!imag', complex(0,1)
DEFSYSV, '!twopi', 2*!dpi


print,!twopi


CHeers,
bob
Re: Defining constants in IDL? [message #31314 is a reply to message #31307] Sat, 22 June 2002 09:55 Go to previous messageGo to next message
ronn is currently offline  ronn
Messages: 123
Registered: April 1999
Senior Member
in article af0nid$1ets$1@agate.berkeley.edu, Marshall Perrin at
mperrin+news@arkham.berkeley.edu wrote on 6/21/02 10:31 PM:

> Dominic Zarro <dzarro@yahoo.com> wrote:
>> IDL is very forgiving. Just define a constant to be any name and set its
>> value. For example,
>>
>> IDL> a = 100
>>
>> Just be careful not to redefine and, hence, overwrite the variable 'a'.
>
> The problem with this approach is that it is only visible within one
> particular file. There's no mechanism akin to C's header files for
> getting a constant into multiple source files, something I frequently find
> myself missing.

Hi Marshall,

Actually there is something similiar to including a header file. What you
need is a file with no header (i.e. pro or function as the first line) and
no end statement. For example,

a = 0
True = 1
False = 0
yes = 'YES'

could be saved in a file called constants.pro.

To include this in your own code you would do this.

pro myProcedure, p1, p2

@constants

...
...

end

The @ sign acts as an include statement to the compiler.

-Ronn


--
Ronn Kling
KRS, inc.
email: ronn@rlkling.com
"Application Development with IDL"� programming book updated for IDL5.5!
"Calling C from IDL, Using DLM's to extend your IDL code"
http://www.rlkling.com/
Re: Defining constants in IDL? [message #31315 is a reply to message #31314] Fri, 21 June 2002 19:31 Go to previous messageGo to next message
mperrin+news is currently offline  mperrin+news
Messages: 81
Registered: May 2001
Member
Dominic Zarro <dzarro@yahoo.com> wrote:
> IDL is very forgiving. Just define a constant to be any name and set its
> value. For example,
>
> IDL> a = 100
>
> Just be careful not to redefine and, hence, overwrite the variable 'a'.

The problem with this approach is that it is only visible within one
particular file. There's no mechanism akin to C's header files for
getting a constant into multiple source files, something I frequently find
myself missing. You can work around this using common blocks, but that's
has its own problems. Perhaps the best solution is user-defined system
variables but even that seems rather kludgy.

- Marshall
Re: Defining constants in IDL? [message #31316 is a reply to message #31315] Fri, 21 June 2002 19:18 Go to previous messageGo to next message
Dominic Zarro is currently offline  Dominic Zarro
Messages: 7
Registered: July 1998
Junior Member
IDL is very forgiving. Just define a constant to be any name and set its
value. For example,

IDL> a = 100

Just be careful not to redefine and, hence, overwrite the variable 'a'.
Re: Defining constants in IDL? [message #31354 is a reply to message #31233] Fri, 28 June 2002 15:51 Go to previous message
jeyadev is currently offline  jeyadev
Messages: 78
Registered: February 1995
Member
In article <afg4st$hrf$1@skates.gsfc.nasa.gov>,
William Thompson <thompson@orpheus.nascom.nasa.gov> wrote:
> I believe that the @ statement also works in PVWave. However, you have to be
> careful with @. You can't have any leading spaces, or spaces between it and
> the filename. So, you should change "@ junk" to "@junk", and make sure that
> the @ is all the way over to the left.

Thanks. Will give it a shot on Monday. Wonder why there isn't a simple
"include" command!

--

Surendar Jeyadev jeyadev@wrc.xerox.bounceback.com

Remove 'bounceback' for email address
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Delvar?
Next Topic: Re: write_jpeg and TVRD()

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

Current Time: Wed Oct 08 14:55:43 PDT 2025

Total time taken to generate the page: 0.00829 seconds