Menu

Double DO UNTIL and stop working

2008-05-25
2013-05-30
  • Internet Lam

    Internet Lam - 2008-05-25

    Hi admin,

    I'm writing my code for dual thermometer and discovered that the GCBASIC capable to compile the code nicely but it doesn't run when I include both subroutines that contain DO UNTIL command.

    The skeleton of my program is:

    #chip config bla bla bla...

    mainloop:
        Select Case variable
            Case 1
                Goto Sub1

            Case 2
                Goto Sub2
        End Select
    Goto mainloop

    Sub Sub1
        InitSub1 = False
        Do UNTIL InitSub1 = True
            Bla bla bla
            Conditions
                InitSub1 = True
        Loop
    End Sub

    Sub Sub2
        InitSub2 = False
        Do UNTIL InitSub2 = True
            Bla bla bla
            Conditions
                InitSub2 = True
        Loop
    End Sub

    After detail investigation, the conclusion that I can make is that most likely this is a bug of QCBASIC. The reason is, if we only include either Goto Sub1 or Goto Sub2 in the main loop (i.e. comment out Goto Sub1 or Goto Sub2, the PIC will work just fine. When the main loop included both routines, the PIC is simply not running (hang I believe). I've verified the running status of PIC using LCD and also blinking LED in case you are in doubt.

    Would appreciate if you would investigate in detail.

     
    • Nobody/Anonymous

      Correction, the mainloop should be:

      mainloop:
      Select Case variable
      Case 1
      GoSub Sub1

      Case 2
      Goto Sub2
      End Select
      GoSub mainloop

       
    • Internet Lam

      Internet Lam - 2008-05-27

      Found this in the help file:
      Note that the WHILE or UNTIL and the condition can only be specified once, or not at all. If they are not specified, then the code will repeat endlessly.

      So it is caused by the limitation of GCBASIC itself.

       
    • Hugh Considine

      Hugh Considine - 2008-06-02

      Your code should work, I compiled it (after changing both Gotos to Gosubs) and the assembly looks fine. Could you please email me the entire source file, so I can check it? It's possible that something in one sub is interfering with something in the other - all variables are global in GCBASIC.

      You can have multiple loops in the program, each with either a while or an until. The only thing you can't do is something like this:

      Do while ...
          something
      Loop while ...

      That is, either put something after Do, or put something after Loop, or don't put anything - just don't put something after Do and after Loop in the same loop.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.