While not executing

  1. ‹ Older
  2. 5 years ago

    John F

    2 Feb 2015 Pre-Release Testers, Xojo Pro Omaha, Nebraska

    @Kem T John can you share your source code? I'd like to figure this out.

    Kem, I'd really like to share the code, but this is a commercial application that prevents me from doing that.

    This particular code segment is hundreds of lines long and not just as simple as some who have replied might think. I know it's something strange in this code segment because if I just put the following code before the actual "While" code, it skips over it as well.

    While ((nYROD = 1 and nAFYD > 0) OR nBUUCOST > 0)
    exit
    Wend

    This is a module that is called from a window so there is no possibility of a variable and a property that might be the same name. There are 250 lines of code that are executed before it even gets to this "While" statement. Here is the variable declaration that includes the variables used in the "While" statement. Of course, some of these values will change as it runs through the code, but as I stated, I interrogated the values in the debug just before it got to the "While" and they should allow the While to execute, but it does not.

    dim ACQ As Date = rsASSETS.Field("ACQ").DateValue
    dim nCOST As Double = 0.00
    dim nS179 As Double = 0.00
    dim cITCS As String = ""
    dim nITCA As Double = 0.00
    dim nSALV As Double = 0.00
    dim nYROD As Integer = 1
    dim BONUSTAKEN As Boolean = False
    dim nBONUSPCT As Double = 0.00
    dim nAFYD As Double = 0.00
    dim nBPCT As Double = 0.00
    dim cLISTED As String = ""
    dim nBASE As Double = 0.00
    dim VBUP As Boolean = False
    dim nBUUCOST As Double = 0.00
    dim nACTUALBPCT As Double = 0.00
    dim cSTATUS As String = ""
    dim cSTATUS_SAVE As String = rsASSETS.Field("STATUS").StringValue
    dim nYROD_SAVE As Integer = rsASSETS.Field("YROD").IntegerValue
    dim nACCD As Double = 0.00
    dim nMTYR As Double = 0.00
    dim nNXYR As Double = 0.00 // NEXT YEAR'S DEPR

    I'm going to try Michael's suggestion and see if I can clear the cache. I'm running on a Mac, but will test on Windows to see if I get the same behavior and report back.

  3. Gavin S

    2 Feb 2015 Pre-Release Testers UK

    @John F There are 250 lines of code that are executed before it even gets to this "While" statement.

    As a quick test, can you try temporarily putting the While statement at the top of your code, just after your variable declarations?

  4. John F

    2 Feb 2015 Pre-Release Testers, Xojo Pro Omaha, Nebraska

    Gavin

    Nice suggestion and one that I thought of before. Here is the code entered directly after the variable declaration:

    nBUUCOST = 2419.25
    while ((nYROD = 1 and nAFYD > 0) or nBUUCOST > 0)
    MsgBox "hello"
    Exit
    Wend

    Note that I had to change the nBUUCOST to a value greater than 0 or it wouldn't get into the while.

    Even after doing that, it still does not execute the msgbox in the "while", just jumps to the Wend.

    I also tried this:

    nAFYD = 15
    while ((nYROD = 1 and nAFYD > 0) or nBUUCOST > 0)
    MsgBox "hello"
    Exit
    Wend

    after the variable assignment, it jumps to the Wend.

    Very strange!

  5. John F

    2 Feb 2015 Pre-Release Testers, Xojo Pro Omaha, Nebraska

    I know how bizarre this has to sound, but I've been working in Xojo for over 4 years and have a number of applications developed in it so I'm not a novice when it comes to this kind of stuff. I put a message box just before the while to verify that the values shown in the debugger are valid and they are as they should be.

    I've already found a work-around so this is not holding anything up, but if there is something in the code that is causing this, I want to know what it is so I can determine if it's me or Xojo.

  6. Kem T

    2 Feb 2015 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut
    Edited 5 years ago

    What happens if you write it like this instead:

    while (nYROD = 1 and nAFYD > 0.0) or nBUUCOST > 0.0
  7. Harrie W

    2 Feb 2015 Crossville, Tennessee, USA

    Kem, I was just about to press the Reply button when your reply with the same question appeared. In my 55+ years of programming I have seen oddities corrected by things like you just suggested. Once had a PL/I program that would abend half way through saying that a variable had no value. I could put a trace on that variable and it had a value right up to the statement that would fail. After an agonizing couple of days I just did a global rename on the variable and the program then worked. The original name was not in the list of restricted names, no where near a restricted name. Go figure.

  8. John F

    2 Feb 2015 Pre-Release Testers, Xojo Pro Omaha, Nebraska

    Kem

    I assume you mean with the implicit decimal points? I'll try it right now. I can verify that I get the same behavior in Windows. Skips over the While.

    Testing right now, Xojo just crashed so I have to do over... back in a minute.

  9. John F

    2 Feb 2015 Pre-Release Testers, Xojo Pro Answer Omaha, Nebraska

    Boy do I feel like an idiot.

    OK, so I thought you were on to something because my simplified test worked with the explicit decimals points. But then I decided to go back to my original code and found that when Xojo is running through a While loop, it jumps to the Wend FIRST, then cycles back up to the line of code AFTER the "While" statement. I guess I wasn't tracking it through far enough to see this behavior because when it skipped all the code inside the "While" and jumped to the Wend, I thought it was completely skipping that code. It wasn't.

    Problem solved... chalk this up to user error ( and stupidity ).

    Thanks for everyone's feedback... Obviously, no one has actually watched a While execute like I was or they may have said, hey, keep stepping through the code and it will cycle back.

  10. Kem T

    2 Feb 2015 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    Actually, that had occurred to me, but since you said

    @John F I've been working in Xojo for over 4 years and have a number of applications developed in it so I'm not a novice when it comes to this kind of stuff.

    :D

    Don't worry about it, we've all been there. Except me, of course.

  11. Gavin S

    2 Feb 2015 Pre-Release Testers UK

    @John F it jumps to the Wend FIRST, then cycles back up to the line of code AFTER the "While" statement.

    Actually, I didn't know it did that although I rarely use while...wend. So maybe we all learned something today. Except Kem, of course.

  12. John F

    2 Feb 2015 Pre-Release Testers, Xojo Pro Omaha, Nebraska

    Thanks to all who responded and shared in my learning experience.

  13. Tim H

    2 Feb 2015 Pre-Release Testers Portland, OR USA

    That sounds like new behavior. I've never seen it do that.

  14. Michel B

    2 Feb 2015 Pre-Release Testers, Xojo Pro RubberViews.com

    In While, the expression is evaluated upon entry, then execution within the loop is linear.

    This shows it very clearly :

      dim whi as integer = 1
      while whi = 1
        system.debuglog "1"
        whi = 1
        system.debuglog "2"
        exit
      wend

    If, as John says, execution started at Wend, "1" and "2" would never show up.

    Urban legends abound...

  15. Kem T

    2 Feb 2015 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    John's talking about the steps the debugger takes as you're stepping through that loop. In your code, if you set a break point at the dim statement, then stepped through, you'd see it go to the while line, then to wend, then back to system.debuglog.

  16. Gavin S

    2 Feb 2015 Pre-Release Testers UK
    Edited 5 years ago

    @Kem T John's talking about the steps the debugger takes as you're stepping through that loop. In your code, if you set a break point at the dim statement, then stepped through, you'd see it go to the while line, then to wend, then back to system.debuglog.

    To double-down on this nerdiness, it doesn't actually go to the While line, just straight to Wend and then back to the first line inside the while statement.

    The debugger skips over Do but at least it doesn't go straight to the Loop Until, it goes to the first statement, as you'd expect.

    Similarly, the debugger appears to skip over the Do Until line and it goes to the first statement inside the loop.

    A For loop works as you'd expect, showing the debugger go to the For line and then inside the For loop.

    Initially I thought that it was skipping the While and Do lines as there's nothing in there for the debugger to evaluate. But there is something for the debugger to evaluate in Do Until, so that doesn't explain it. And none of this explains why it goes to Wend first.

  17. Dale A

    2 Feb 2015 San Diego, California, USA

    (This takes me back to the days I was writing BASIC language interpreters.) The code flow in loops of any kind have to test exit conditions not only at the end the loop but also on loop entry. So with Do and While loops it jumps to the end to test if the entry condition matches or exceeds the exit condition. If not the program pointer returns to the start of the loop and processes the statements until it again reaches the point where the condition testing occurs.

    For loops are handled differently since the statement also includes initialization of the loop variable and limits.

    Ok, so boiling this all down for simplicity...a For statement is an executable statement; Do and While statements are not in the sense that they don't really do anything except set limit conditions.

    Did that make any sense?

  18. Will S

    2 Feb 2015 Santa Cruz 

    @Tim H That sounds like new behavior. I've never seen it do that.

    It is new.

    The stepping sequence in Xojo 13r4.1 lands on while, not wend, but reversed by 14r3.0. Do loops step the same.

    break              //0
      
    dim i As integer   //1
      
    while i < 3        //2
        
      i = i + 1        //3
        
    wend               //4
      
    beep               //5
    
    
    
    13r4.1:   0, 1, 2, 3, 2, 3, 2, 3, 2, 5, end sub
    
    14r3.0:   0, 1, 4, 3, 4, 3, 4, 3, 4, 5, end sub
  19. Michel B

    3 Feb 2015 Pre-Release Testers, Xojo Pro RubberViews.com

    @Kem T John's talking about the steps the debugger takes as you're stepping through that loop. In your code, if you set a break point at the dim statement, then stepped through, you'd see it go to the while line, then to wend, then back to system.debuglog.

    You are right. It does step to wend before going to the first instruction in the loop. But for all intents and purpose, it does not change anything as far as practical execution of the code is concerned.

  20. 4 weeks ago

    Robert B

    Sep 17 Pre-Release Testers, Xojo Pro Cincinnati, Ohio

    Interesting old thread...I just ran into this myself trying to test code inside a while...but the debugger appeared to be stepping over the code -- so I would stop execution and try to figure out why. This seems like really odd behavior in the debugger to me...however now that I've seen it.... I guess I'll know next time.

  21. Norman P

    Sep 17 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    I was sure there was already a bug report about this behaviour but I cant find it in feedback if there is one

    Feedback Case #57500

or Sign Up to reply!