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

Home » Public Forums » archive » Re: strange behaviour of .skip command
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: strange behaviour of .skip command [message #60370] Thu, 15 May 2008 11:19
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Manodeep Sinha writes:

> So, my understanding is that you are fine as long as using .skip does
> not take you to the end of a control flow statement. If using .skip
> does take you to a endif/endfor statement, then the code will behave
> somewhat unexpectedly.

I think the point is that .SKIP doesn't follow program
control flow at all. It just skips the next command in the
file, whatever it is.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: strange behaviour of .skip command [message #60371 is a reply to message #60370] Thu, 15 May 2008 11:01 Go to previous message
manodeep@gmail.com is currently offline  manodeep@gmail.com
Messages: 33
Registered: June 2006
Member
On May 15, 9:21 am, pgri...@gmail.com wrote:
>
> Simply put a "stop" instead of your random test, and resume execution
> with .continue.
> Then there is no need to use .skip.
>
> Cheers,
> Paolo

In this case, I completely agree but the need to use a .skip does
arise if there happens to be one line of offending code. Using .skip
in such a case could lead to "for loops" not being completely
executed, or execution falling through to the "else" part of an "if-
else" condition.

So, my understanding is that you are fine as long as using .skip does
not take you to the end of a control flow statement. If using .skip
does take you to a endif/endfor statement, then the code will behave
somewhat unexpectedly.

As David pointed out, the behaviour of .skip can have implications
that are not immediately obvious !

Cheers,
Manodeep
Re: strange behaviour of .skip command [message #60373 is a reply to message #60371] Thu, 15 May 2008 06:21 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Manodeep Sinha wrote:
> Hello everyone,
>
> In the fine tradition of *trying* to get things done quick, I have a
> code segment that looks like :
>
> if {some condition} then begin
> .
> .
> {some random text to make the code break}
>
> endif else begin
> .
> .
> endelse
>
> The code breaks at the random text, I check for the variables and
> conditions that were set in the "if part", and if all is well, I issue
> a .skip and a .continue. Now, it turns out that under such conditions
> (if the random text is located right before the endif statement), the
> code execution actually proceeds through the else-endelse segment as
> well. However, if there is any other statement between the random text
> and the endif statement, then the code execution does not go into the
> else-endelse segment.

Simply put a "stop" instead of your random test, and resume execution
with .continue.
Then there is no need to use .skip.

Cheers,
Paolo

>
> Granted this is quite an unique situation to find oneself in, but
> having spent the better part of a day trying to track this down, I
> thought I would check with the group and see if this was a
> reproducible behaviour.
>
> Is my understanding of .skip incorrect ? Does it skip through more
> than 1 line even when invoked without an additional parameter ?
>
> In any case, it boggles my mind seeing code go through both the "if"
> and "else" part in one execution !
>
> Cheers,
> Manodeep
Re: strange behaviour of .skip command [message #60376 is a reply to message #60373] Wed, 14 May 2008 20:46 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Manodeep Sinha writes:

> Is my understanding of .skip incorrect ? Does it skip through more
> than 1 line even when invoked without an additional parameter ?
>
> In any case, it boggles my mind seeing code go through both the "if"
> and "else" part in one execution !

Here is what the .SKIP documentation says:

;*****************************************
Note that .SKIP does not execute or evaluate the code it is skipping.
Rather, it arbitrarily alters the current program counter to the nth
physical statement following the current point. This has implications
that may not be obvious on initial consideration:
;*****************************************

I would say what you see is consistent with this
statement.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Coyote Color Program Updates
Next Topic: Fun with IDL 7

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

Current Time: Fri Oct 10 09:11:46 PDT 2025

Total time taken to generate the page: 1.19941 seconds