Correct format of "included" files (using "at" sign)

Correct format of "included" files (using "at" sign)

Post by Dave Stee » Thu, 03 Mar 1994 04:12:34



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.

Can anyone tell me what I should be doing differently?  I've read
the manual and the FAQ, but no luck.  If anyone can help me with
this, we should put the disseminated knowledge into the FAQ.

Thanks to all.  Perhaps a posted response is appropriate, since
the question may be of general interest.

Dave

--

Department of Physics and Astronomy   |  SPAN     : CANCAL::STEELE
The University of Calgary             |  Phone    : +1 403 220 8651
OPINIONS EXPRESSED WITHIN ARE MY OWN AND NOT THOSE OF THE UNIVERSITY OF CALGARY

 
 
 

Correct format of "included" files (using "at" sign)

Post by Kevin Spenc » Thu, 03 Mar 1994 04:30:46



>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.

[deleted]

>Dave
>--

>Department of Physics and Astronomy   |  SPAN     : CANCAL::STEELE
>The University of Calgary             |  Phone    : +1 403 220 8651
>OPINIONS EXPRESSED WITHIN ARE MY OWN AND NOT THOSE OF THE UNIVERSITY OF CALGARY

Dave,

Yes, it's frustrating that they don't document the differences in syntax
between compiled routines and the "script" files.  As far as I know, you
have to keep statements to one line, and can't use block statements.  IDL
just treats the commands as if they were issued in interactive mode.

Kevin

-----------------------------------------------------------
Kevin Spencer
Cognitive Psychophysiology Laboratory and Beckman Institute
University of Illinois at Urbana-Champaign

-----------------------------------------------------------

 
 
 

Correct format of "included" files (using "at" sign)

Post by Paul Ricchiaz » Thu, 03 Mar 1994 10:26:04


|> 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.

___________________________________________________________________________

Earth Space Research Group, UCSB      
___________________________________________________________________________

 
 
 

Correct format of "included" files (using "at" sign)

Post by Brian Jack » Thu, 03 Mar 1994 03:11:12




>Subject: Correct format of "included" files (using "at" sign)
>Date: Tue, 1 Mar 1994 19:12:34 GMT
>Keywords: IDL, "at" sign, substituted code
>I'm trying to use the "at" sign (the $%^&*! 'xrn' editor won't let

...Text deleted

>--

>Department of Physics and Astronomy   |  SPAN     : CANCAL::STEELE
>The University of Calgary             |  Phone    : +1 403 220 8651
>OPINIONS EXPRESSED WITHIN ARE MY OWN AND NOT THOSE OF THE UNIVERSITY OF CALGARY

Could you be more specific about what you're trying?  On the PC I can make a
program TEST.PRO as follows:

--------------------------------------------------------------------------
pro TEST


print,'The end'

end
---------------------------------------------------------------------------

where the file c:\idl\test.1 is just:

--------------------------------------------------------------------------
FOR i=0,10 DO BEGIN
 print,i
ENDFOR
---------------------------------------------------------------------------

and it works fine.  The only way I can create problems is to put a space

basically what you want to do, or have I misunderstood?

 
 
 

Correct format of "included" files (using "at" sign)

Post by Ray Stern » Fri, 04 Mar 1994 00:02:04



>Yes, it's frustrating that they don't document the differences in syntax
>between compiled routines and the "script" files.  As far as I know, you
>have to keep statements to one line, and can't use block statements.  IDL
>just treats the commands as if they were issued in interactive mode.


  specified file at this point"  where that text must be appropriate

  is called a batch file and must have the same syntax as you would
  type in that mode.  If you are in compile mode the file is called
  an include file and the text may have the syntax used in routines.


  Johns Hopkins University        North latitude 39.16 degrees.
  Applied Physics Laboratory      West longitude 76.90 degrees.
  Laurel, MD 20723-6099