Re: while loop crashes [message #71129] |
Wed, 02 June 2010 05:54 |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Jun 1, 3:43 pm, mgalloy <mgal...@gmail.com> wrote:
> On 6/1/10 7:47 AM, Bennett wrote:
>
>> These are the types of situations where I wish IDL had MATLABs
>> capability of evaluating highlighted chunks of code.
>
> There is a "Run selected text" item in the context menu for selected
> text in the Workbench editor.
>
> Mike
> --www.michaelgalloy.com
> Research Mathematician
> Tech-X Corporation
I guess I just automatically thought they would never include it.
Hello productivity.
|
|
|
Re: while loop crashes [message #71130 is a reply to message #71129] |
Wed, 02 June 2010 01:48  |
hovru
Messages: 3 Registered: June 2010
|
Junior Member |
|
|
On Jun 1, 3:27 am, lila hadji <lhad...@gmail.com> wrote:
> On 1 juin, 12:18, Spon <christoph.b...@gmail.com> wrote:
>
>
>
>> On Jun 1, 8:51 am, hovru <h.rube...@gmail.com> wrote:
>
>>> Wouldn't you not need the "Pro" and "End" if it's not a program, just
>>> a script (such as when you use "Journal")?
>>> Also, leaving out the "return" should be fine, since there is only one
>>> level, right?
>
>>> Thanks.
>
>> Looks like you can't have loops or statements in batch files; every
>> statement has to be complete, just like if you were using the command
>> line.
>
>> So, this works fine, but your program does not:
>> ---
>> print, 'start while loop'
>> j=2
>> while (j NE 10) do j=j+1
>
>> print, 'done', j
>> ---
>
>> Have a look at the helpfile for 'Executing Batch Jobs in IDL', I
>> guess.
>> I've always wondered why people even use batch mode, when procedures
>> and functions are almost as easy to write. What is the advantage of
>> batch mode?
>
>> No, you don't need the 'return', but what harm is it doing? Plus, if
>> you decide to modify the code to pass variables or keywords to it
>> later, you might wonder why they never come back. :-)
>
>> Chris
>
> Actually, when you want to run a script, you can remose the pro line,
> and add (optionally) $Main$ at the beginning (to speed up the
> performances)
> You can also remove the return line but you have absolutely to keep
> the end line.
> ; files simpletest.pro
> $Main$
> print, 'start while loop'
> j=2
> while (j NE 10) do begin
> print,j
> j=j+1
> print, j
> endwhile
>
> print, 'done'
> end
>
> and all you have to do in IDL screen is tape .run simpletest.pro
> Hope it helps a little
> Cheers
> Lila
It seems awkward, but it makes sense.
Thanks for all the help.
|
|
|
Re: while loop crashes [message #71133 is a reply to message #71130] |
Tue, 01 June 2010 23:03  |
lila hadji
Messages: 7 Registered: June 2010
|
Junior Member |
|
|
On 1 juin, 22:08, mgalloy <mgal...@gmail.com> wrote:
> On 6/1/10 4:27 AM, lila hadji wrote:
>
>> Actually, when you want to run a script, you can remose the pro line,
>> and add (optionally) $Main$ at the beginning (to speed up the
>> performances)
>
> I don't think your $Main$ line is doing anything, $ is the continuation
> character in functions/procedures/main-level program and any characters
> that appear after it are ignored. For example:
>
> pro test
> $This is a really confusing comment
>
> print, 5
> end
>
> This "continues" a blank line with the following blank line, making a
> valid (blank) IDL statement.
>
> Mike
> --www.michaelgalloy.com
> Research Mathematician
> Tech-X Corporation
Fair enough. I said what I was told sometimes ago by someone who's
used to IDL since a long time. I guess we always should check things
out for ourselves, don't we?!
Thank you very much for the explanation.
Cheers
Lila
|
|
|
Re: while loop crashes [message #71140 is a reply to message #71133] |
Tue, 01 June 2010 13:08  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 6/1/10 4:27 AM, lila hadji wrote:
> Actually, when you want to run a script, you can remose the pro line,
> and add (optionally) $Main$ at the beginning (to speed up the
> performances)
I don't think your $Main$ line is doing anything, $ is the continuation
character in functions/procedures/main-level program and any characters
that appear after it are ignored. For example:
pro test
$This is a really confusing comment
print, 5
end
This "continues" a blank line with the following blank line, making a
valid (blank) IDL statement.
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: while loop crashes [message #71141 is a reply to message #71140] |
Tue, 01 June 2010 12:49  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 6/1/10 4:18 AM, Spon wrote:
> I've always wondered why people even use batch mode, when procedures
> and functions are almost as easy to write. What is the advantage of
> batch mode?
I think batch files have very special purpose uses:
1. You can include code into multiple function/procedure using batch
files, e.g., error handling code that would normally be copy-and-pasted
into many routines.
2. To make a build script callable from the main-level since you can
put executive statements from batch files that are called from the
main-level.
Any other uses for batch files? I go with main-level programs for a lot
of simple/throw-away script stuff (since I can make it into a
function/procedure fairly easily if I don't actually throw it away).
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: while loop crashes [message #71142 is a reply to message #71141] |
Tue, 01 June 2010 12:43  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 6/1/10 7:47 AM, Bennett wrote:
> These are the types of situations where I wish IDL had MATLABs
> capability of evaluating highlighted chunks of code.
There is a "Run selected text" item in the context menu for selected
text in the Workbench editor.
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: while loop crashes [message #71147 is a reply to message #71142] |
Tue, 01 June 2010 06:47  |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Jun 1, 6:27 am, lila hadji <lhad...@gmail.com> wrote:
> On 1 juin, 12:18, Spon <christoph.b...@gmail.com> wrote:
>
>> On Jun 1, 8:51 am, hovru <h.rube...@gmail.com> wrote:
>
>>> Wouldn't you not need the "Pro" and "End" if it's not a program, just
>>> a script (such as when you use "Journal")?
>>> Also, leaving out the "return" should be fine, since there is only one
>>> level, right?
>
>>> Thanks.
>
>> Looks like you can't have loops or statements in batch files; every
>> statement has to be complete, just like if you were using the command
>> line.
>
>> So, this works fine, but your program does not:
>> ---
>> print, 'start while loop'
>> j=2
>> while (j NE 10) do j=j+1
>
>> print, 'done', j
>> ---
>
>> Have a look at the helpfile for 'Executing Batch Jobs in IDL', I
>> guess.
>> I've always wondered why people even use batch mode, when procedures
>> and functions are almost as easy to write. What is the advantage of
>> batch mode?
>
>> No, you don't need the 'return', but what harm is it doing? Plus, if
>> you decide to modify the code to pass variables or keywords to it
>> later, you might wonder why they never come back. :-)
>
>> Chris
>
> Actually, when you want to run a script, you can remose the pro line,
> and add (optionally) $Main$ at the beginning (to speed up the
> performances)
> You can also remove the return line but you have absolutely to keep
> the end line.
> ; files simpletest.pro
> $Main$
> print, 'start while loop'
> j=2
> while (j NE 10) do begin
> print,j
> j=j+1
> print, j
> endwhile
>
> print, 'done'
> end
>
> and all you have to do in IDL screen is tape .run simpletest.pro
> Hope it helps a little
> Cheers
> Lila
These are the types of situations where I wish IDL had MATLABs
capability of evaluating highlighted chunks of code.
|
|
|
Re: while loop crashes [message #71150 is a reply to message #71147] |
Tue, 01 June 2010 03:27  |
lila hadji
Messages: 7 Registered: June 2010
|
Junior Member |
|
|
On 1 juin, 12:18, Spon <christoph.b...@gmail.com> wrote:
> On Jun 1, 8:51 am, hovru <h.rube...@gmail.com> wrote:
>
>> Wouldn't you not need the "Pro" and "End" if it's not a program, just
>> a script (such as when you use "Journal")?
>> Also, leaving out the "return" should be fine, since there is only one
>> level, right?
>
>> Thanks.
>
> Looks like you can't have loops or statements in batch files; every
> statement has to be complete, just like if you were using the command
> line.
>
> So, this works fine, but your program does not:
> ---
> print, 'start while loop'
> j=2
> while (j NE 10) do j=j+1
>
> print, 'done', j
> ---
>
> Have a look at the helpfile for 'Executing Batch Jobs in IDL', I
> guess.
> I've always wondered why people even use batch mode, when procedures
> and functions are almost as easy to write. What is the advantage of
> batch mode?
>
> No, you don't need the 'return', but what harm is it doing? Plus, if
> you decide to modify the code to pass variables or keywords to it
> later, you might wonder why they never come back. :-)
>
> Chris
Actually, when you want to run a script, you can remose the pro line,
and add (optionally) $Main$ at the beginning (to speed up the
performances)
You can also remove the return line but you have absolutely to keep
the end line.
; files simpletest.pro
$Main$
print, 'start while loop'
j=2
while (j NE 10) do begin
print,j
j=j+1
print, j
endwhile
print, 'done'
end
and all you have to do in IDL screen is tape .run simpletest.pro
Hope it helps a little
Cheers
Lila
|
|
|
Re: while loop crashes [message #71151 is a reply to message #71150] |
Tue, 01 June 2010 03:18  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Jun 1, 8:51 am, hovru <h.rube...@gmail.com> wrote:
> Wouldn't you not need the "Pro" and "End" if it's not a program, just
> a script (such as when you use "Journal")?
> Also, leaving out the "return" should be fine, since there is only one
> level, right?
>
> Thanks.
Looks like you can't have loops or statements in batch files; every
statement has to be complete, just like if you were using the command
line.
So, this works fine, but your program does not:
---
print, 'start while loop'
j=2
while (j NE 10) do j=j+1
print, 'done', j
---
Have a look at the helpfile for 'Executing Batch Jobs in IDL', I
guess.
I've always wondered why people even use batch mode, when procedures
and functions are almost as easy to write. What is the advantage of
batch mode?
No, you don't need the 'return', but what harm is it doing? Plus, if
you decide to modify the code to pass variables or keywords to it
later, you might wonder why they never come back. :-)
Chris
|
|
|
Re: while loop crashes [message #71153 is a reply to message #71151] |
Tue, 01 June 2010 00:51  |
hovru
Messages: 3 Registered: June 2010
|
Junior Member |
|
|
On Jun 1, 12:38 am, Spon <christoph.b...@gmail.com> wrote:
> On Jun 1, 7:53 am, hovru <h.rube...@gmail.com> wrote:
>
>> I have been tried several times to run the following script in (by
>> calling it through a .pro file) but it always causes it to crash. It
>> seems simple enough, yet I can't figure out why it won't work.
>
> ---
> pro simpletest
> print, 'start while loop'
> j=2
> while (j NE 10) do begin
> print,j
> j=j+1
> print, j
> endwhile
>
> print, 'done'
> return
> end
> ---
>
>> simpletest
>
> start while loop
> 2
> 3
> 3
> 4
> 4
> 5
> 5
> 6
> 6
> 7
> 7
> 8
> 8
> 9
> 9
> 10
> done
> ---
>
> Works fine for me.
>
> Regards,
> Chris
Wouldn't you not need the "Pro" and "End" if it's not a program, just
a script (such as when you use "Journal")?
Also, leaving out the "return" should be fine, since there is only one
level, right?
Thanks.
|
|
|
Re: while loop crashes [message #71154 is a reply to message #71153] |
Tue, 01 June 2010 00:38  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Jun 1, 7:53 am, hovru <h.rube...@gmail.com> wrote:
> I have been tried several times to run the following script in (by
> calling it through a .pro file) but it always causes it to crash. It
> seems simple enough, yet I can't figure out why it won't work.
---
pro simpletest
print, 'start while loop'
j=2
while (j NE 10) do begin
print,j
j=j+1
print, j
endwhile
print, 'done'
return
end
---
> simpletest
start while loop
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
done
---
Works fine for me.
Regards,
Chris
|
|
|