Re: Defining constants in IDL? [message #31233] |
Thu, 27 June 2002 15:51  |
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   |
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 #31307 is a reply to message #31306] |
Mon, 24 June 2002 06:04   |
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   |
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/
|
|
|
|
|
|