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

Home » Public Forums » archive » Re: Begin statement
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: Begin statement [message #3258] Fri, 06 January 1995 04:29
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
In article <gurman-0501951345270001@barkochba.gsfc.nasa.gov> gurman@uvsp.gsfc.nasa.gov (Joseph B. Gurman) writes:
>> Actually, on can use BEGIN and END statements from the command line, but one
>> has to fit in the entire command onto a single command line, e.g.
>>
>> IDL> FOR I=1,10 DO BEGIN & PRINT,I & HELP,I & ENDFOR
>
> In fact, on the command line, one can even omit the END[FOR] --- as
> the original poster had it:
> (I never knew it worked until David Stern did it while showing me


As long as we are splitting hairs, the first & is not required at the command
line either.

IDL> for i = 0, 9 do begin print,i & help,i

works just as well.

--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: j.m.zawodny@larc.nasa.gov MS-475, Hampton VA, 23681-0001
TCP/IP: ko4lw@ko4lw.ampr.org Packet: ko4lw@n4hog.va.usa.na
Re: Begin statement [message #3259 is a reply to message #3258] Thu, 05 January 1995 10:45 Go to previous message
gurman is currently offline  gurman
Messages: 82
Registered: August 1992
Member
In article <3efcu3$6br@post.gsfc.nasa.gov>,
thompson@orpheus.nascom.nasa.gov (William Thompson) wrote:

> hartl@clouzot.imo.physik.uni-muenchen.de (Ingmar Hartl) writes:
>
>> In article <hahn.74.00145964@hrz.th-darmstadt.de>
hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
>>> and it looks as if begin is immediately followed by end:
>>> IDL> repeat begin
>>> All rights reserved. Unauthorized reproduction prohibited.
>>> & END
>>> ^
>>> % Syntax error.
>
>> Same happened to me.
>
>> It worked, after I wrote a procedure with this statements.
>
>> I think, it is only allowed to use BEGIN and END statements
>> in procedures and functions. I found nothing to this point
>> in the User's Guide...
>
>> Ingmar Hartl.
>
> Actually, on can use BEGIN and END statements from the command line, but one
> has to fit in the entire command onto a single command line, e.g.
>
> IDL> FOR I=1,10 DO BEGIN & PRINT,I & HELP,I & ENDFOR

In fact, on the command line, one can even omit the END[FOR] --- as
the original poster had it:

IDL> for i = 0, 9 do begin & print,i & help,i

(I never knew it worked until David Stern did it while showing me
something or other.)

Joe Gurman

>
> (It actually doesn't matter if one uses END or ENDFOR. Always remembering to
> use ENDFOR, ENDIF, ENDWHILE, etc. leads to more readable code and makes it
> easier for IDL to point out where any errors might occur.)
>
> If one only wants a single statement within a FOR loop, then one can omit the
> BEGIN and ENDFOR statements, e.g.
>
> IDL> FOR I=1,10 DO PRINT,I
>
> If one can't fit the entire loop onto a single line, then one needs to write a
> procedure, either by editing a file or by using .RUN, e.g.
>
> IDL> .RUN
> - FOR I=1,10 DO BEGIN
> - PRINT, I
> - HELP, I
> - ENDFOR
> - END
>
> William Thompson

--
J.B. Gurman / Solar Physics Branch/ NASA Goddard Space Flight Center/
Greenbelt MD 20771 USA / gurman@uvsp.gsfc.nasa.gov
| Federal employees are still prohibited from holding opinions while|
| at work. Therefore, any opinions expressed herein are somebody |
| else's. |
Re: Begin statement [message #3260 is a reply to message #3259] Wed, 04 January 1995 16:02 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
hartl@clouzot.imo.physik.uni-muenchen.de (Ingmar Hartl) writes:

> In article <hahn.74.00145964@hrz.th-darmstadt.de> hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
>> and it looks as if begin is immediately followed by end:
>> IDL> repeat begin
>> All rights reserved. Unauthorized reproduction prohibited.
>> & END
>> ^
>> % Syntax error.

> Same happened to me.

> It worked, after I wrote a procedure with this statements.

> I think, it is only allowed to use BEGIN and END statements
> in procedures and functions. I found nothing to this point
> in the User's Guide...

> Ingmar Hartl.

Actually, on can use BEGIN and END statements from the command line, but one
has to fit in the entire command onto a single command line, e.g.

IDL> FOR I=1,10 DO BEGIN & PRINT,I & HELP,I & ENDFOR

(It actually doesn't matter if one uses END or ENDFOR. Always remembering to
use ENDFOR, ENDIF, ENDWHILE, etc. leads to more readable code and makes it
easier for IDL to point out where any errors might occur.)

If one only wants a single statement within a FOR loop, then one can omit the
BEGIN and ENDFOR statements, e.g.

IDL> FOR I=1,10 DO PRINT,I

If one can't fit the entire loop onto a single line, then one needs to write a
procedure, either by editing a file or by using .RUN, e.g.

IDL> .RUN
- FOR I=1,10 DO BEGIN
- PRINT, I
- HELP, I
- ENDFOR
- END

William Thompson
Re: Begin statement [message #3263 is a reply to message #3260] Wed, 04 January 1995 23:46 Go to previous message
sigut is currently offline  sigut
Messages: 12
Registered: February 1994
Junior Member
In article <3efcu3$6br@post.gsfc.nasa.gov> thompson@orpheus.nascom.nasa.gov
(William Thompson) writes:
>>
>> I think, it is only allowed to use BEGIN and END statements
>> in procedures and functions. I found nothing to this point
>> in the User's Guide...
>
> Actually, on can use BEGIN and END statements from the command line, but one
> has to fit in the entire command onto a single command line, e.g.
>
> IDL> FOR I=1,10 DO BEGIN & PRINT,I & HELP,I & ENDFOR
>
> If one can't fit the entire loop onto a single line, then one needs to write a
> procedure, either by editing a file or by using .RUN, e.g.
>
> IDL> .RUN
> - FOR I=1,10 DO BEGIN
> - PRINT, I

Actually you can write
for i=1,10 do begin & $
print, i & $ ... etc

With the &'s you make one line and with the $'s you split it when it
gets too long.

Regards, George




--
------------------------------------------------------------ ------------------
George M.Sigut ETH Informatikdienste, Beratung & Schulung, CH-8092 Zurich
Swiss Federal Inst. of Technology, Computing Services, User Support & Training
email: sigut@bs.id.ethz.ch Phone: +41 1 632 5763 Fax: +41 1 632 1225
>>>> >>>>> in case of email problems send the mail to "sigut@acm.org" <<<<<<<<<
------------------------------------------------------------ ------------------
Re: Begin statement [message #3264 is a reply to message #3260] Wed, 04 January 1995 12:36 Go to previous message
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
In article <hahn.74.00145964@hrz.th-darmstadt.de> hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
> Obviously I'm unable to execute compound statements:
>
> When I write the following loop:
> for i=1L, 4 do begin
> help, i
>
> I get
> I LONG = 5
>
> and it looks as if begin is immediately followed by end:
>
> IDL. Version 3.6.1b (windows 3.1).
> Copyright 1989-1994, Research Systems, Inc.
> All rights reserved. Unauthorized reproduction prohibited.
>
> IDL> repeat begin
> All rights reserved. Unauthorized reproduction prohibited.
> & END
> ^
> % Syntax error.
>
> Any clue ?
>
> Norbert Hahn


Yeah, put and endfor statement after the help, i line

for i=1L, 4 do begin
help, i
endfor


--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: j.m.zawodny@larc.nasa.gov MS-475, Hampton VA, 23681-0001
TCP/IP: ko4lw@ko4lw.ampr.org Packet: ko4lw@n4hog.va.usa.na
Re: Begin statement [message #3265 is a reply to message #3264] Wed, 04 January 1995 12:32 Go to previous message
afl is currently offline  afl
Messages: 51
Registered: December 1994
Member
In article <hahn.74.00145964@hrz.th-darmstadt.de>, hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
|> Obviously I'm unable to execute compound statements:
|>
|> When I write the following loop:
|> for i=1L, 4 do begin
|> help, i
|>
|> I get
|> I LONG = 5
|>
|> and it looks as if begin is immediately followed by end:
|>
|> IDL. Version 3.6.1b (windows 3.1).
|> Copyright 1989-1994, Research Systems, Inc.
|> All rights reserved. Unauthorized reproduction prohibited.
|>
|> IDL> repeat begin
|> All rights reserved. Unauthorized reproduction prohibited.
|> & END
|> ^
|> % Syntax error.
|>
|> Any clue ?
|>
|> Norbert Hahn


I wonder if what you meant to do is....
IDL> .run
- for i = 1L, 4 do begin
- help, i
- endfor
- end

or even
IDL> for i = 1L, 4 do help, i

The example you gave is not a complete statement if entered
on the command line.

--

Andrew F. Loughe email: afl@cdc.noaa.gov
University of Colorado, CIRES voice: (303) 492-0707
Campus Box 449 fax: (303) 497-7013
Boulder, CO 80309-0449 USA
Re: Begin statement [message #3266 is a reply to message #3265] Wed, 04 January 1995 13:41 Go to previous message
hartl is currently offline  hartl
Messages: 1
Registered: January 1995
Junior Member
In article <hahn.74.00145964@hrz.th-darmstadt.de> hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
> and it looks as if begin is immediately followed by end:
> IDL> repeat begin
> All rights reserved. Unauthorized reproduction prohibited.
> & END
> ^
> % Syntax error.

Same happened to me.

It worked, after I wrote a procedure with this statements.

I think, it is only allowed to use BEGIN and END statements
in procedures and functions. I found nothing to this point
in the User's Guide...

Ingmar Hartl.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: 3D graphics
Next Topic: PRINT_FILE keyword in MS-WINDOWS ???

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

Current Time: Wed Oct 08 11:33:40 PDT 2025

Total time taken to generate the page: 0.00701 seconds