Re: Correct format of "included" files (using "at" sign) [message #1848 is a reply to message #1847] |
Tue, 01 March 1994 17:26   |
paul
Messages: 22 Registered: June 1991
|
Junior Member |
|
|
In article <Mar1.191234.31054@acs.ucalgary.ca>, steele@wesson.phys.ucalgary.ca (Dave Steele) writes:
|> I'm trying to use the "at" sign (the $%^&*! 'xrn' editor won't let
|> me type it!) to substitute some code into IDL. The procedure is
|> tersely described on p. 2-7 of the User's Guide for v3.1. I'm
|> getting a problem that I think has to do with the format of the
|> code I'm including. It is an IF_THEN_ELSE block with no header
|> line (like PRO ... or FUNCTION ...) and no trailer lines (like
|> RETURN, END, EXIT). If I run the routine that invokes the code
|> substitution, I get syntax errors in the first lines following the
|> invocation. If I add a line saying 'END' to the substituted code,
|> I get dropped back to the IDL> prompt at the end of the substituted
|> code.
...text deleted
The IDL interpreter treats input from a file using the at sign command just
as if the contents of the file were typed in at the prompt. This results in
different behavior than if the file were compiled with the .run command. In
particular multi-line compound statements that contain BEGIN and END statements
are not recognized unless you tell the interpreter that a given command line
is not complete. Here is how to do it...
j=0
k=0
for i=0,10 do begin &$
if i le 2 then begin &$
j=j+1 &$
k=k+2 &$
endif else begin &$
j=j-1 &$
k=k-2 &$
endelse &$
print,i,j,k &$
endfor
If you leave out the &$ the interpreter gets confused because each line of
input is not an independently excutable statement.
____________________________________________________________ _______________
Paul Ricchiazzi Internet: paul@esrg.ucsb.edu
Earth Space Research Group, UCSB
____________________________________________________________ _______________
|
|
|