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

Home » Public Forums » archive » Including files
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
Including files [message #15524] Mon, 24 May 1999 00:00 Go to next message
nilsj is currently offline  nilsj
Messages: 6
Registered: May 1999
Junior Member
The IDL documentation mentions include files, which allows "statements
contained in an include file" to be "textually inserted into the including
file."

However, I can not find any mention or examples of how, exactly, to
include other files. What is the syntax? Are there any examples in the
documentation or sample code that comes with IDL?

Nils
Re: Including files [message #15608 is a reply to message #15524] Thu, 27 May 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
eddie haskell wrote:
> I have no problems with using ENDs in most places. It is a matter of
> properly placed '&'s and '$'s. I saved the following code, which does
> nothing worthwhile, as TEST (without the .pro) and was able to use it in
> $MAIN$, procedures, functions, other loops, and at the command prompt as
> @TEST
> and it also works just by copying the block to the command prompt.
> This works on my Unix box, IDL5.1, but I would be surprised if this was
> version or platform dependent. Granted, this makes the code look a tad
> ugly, but I have had occasions where it was handy to "batchify" a couple
> hundred lines of code like this.
>
> ;;;;;; TEST ;;;;;;;;;;;;;;;;;;;;
> i=0
> FOR j=0,2 do begin $
> i=i+1 & $
> IF (j ge 1) then begin $
> i=i+1 & $
> REPEAT begin $
> i=i+1 & $
> WHILE (i lt 20) do begin $
> i=i+2 & $
> CASE j of & $
> 0 : i=i+1 & $
> else : i=i-1 & $
> ENDCASE & $
> ENDWHILE & $
> ENDREP until (i gt 25) & $
> ENDIF & $
> ENDFOR
> print,i

I guess the bottom line from the previous posts was that as long as you
don't use @ at the command line, you don't need the & $ at the end of
every line of your script. In fact you can include a complete procedure
or function (but why would you want to?), e.g.

;---test.pro---
@include
pro test
print, 'Hello world'
include
end
;---

;---include.pro---
pro include
print, 'This was included'
end
;---

IDL> test
% Compiled module: TEST.
Hello world
This was included

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
Re: Including files [message #15617 is a reply to message #15524] Thu, 27 May 1999 00:00 Go to previous message
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
Liam Gumley wrote:

> block termination statements (ENDFOR, ENDIF, ENDREP, ENDWHILE)
> are only allowed in procedures or functions.

I have no problems with using ENDs in most places. It is a matter of
properly placed '&'s and '$'s. I saved the following code, which does
nothing worthwhile, as TEST (without the .pro) and was able to use it in
$MAIN$, procedures, functions, other loops, and at the command prompt as
@TEST
and it also works just by copying the block to the command prompt.
This works on my Unix box, IDL5.1, but I would be surprised if this was
version or platform dependent. Granted, this makes the code look a tad
ugly, but I have had occasions where it was handy to "batchify" a couple
hundred lines of code like this.

;;;;;; TEST ;;;;;;;;;;;;;;;;;;;;
i=0
FOR j=0,2 do begin $
i=i+1 & $
IF (j ge 1) then begin $
i=i+1 & $
REPEAT begin $
i=i+1 & $
WHILE (i lt 20) do begin $
i=i+2 & $
CASE j of & $
0 : i=i+1 & $
else : i=i-1 & $
ENDCASE & $
ENDWHILE & $
ENDREP until (i gt 25) & $
ENDIF & $
ENDFOR
print,i
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Cheers,
eddie

----- ---- --- --- ---- --- -- --- --- -- -- - - - -
|\ A G Edward Haskell
|\ Center for Coastal Physical Oceanography
|\ Old Dominion University, Norfolk VA 23529
|\ Voice 757.683.4816 Fax 757.683.5550
|\ e-mail haskell*ccpo.odu.edu
----- ---- --- ---- --- --- --- --- -- -- -- - - - -
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Roundoff error in SMOOTH
Next Topic: IDL 5.2 GUI Builder Tutorial ?

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

Current Time: Wed Oct 08 19:39:31 PDT 2025

Total time taken to generate the page: 0.00610 seconds