Wish I still long for Do Loop While()

Discussion in 'B4J Bugs & Wishlist' started by Didier9, Jun 6, 2019.

  1. Didier9

    Didier9 Active Member Licensed User

    Is there any plan to add the common Visual Basic form of the Do Loop:
    Code:
    Do
        
    ' do stuff
    Loop While( some_test )
    I really miss it at times, it would clean up some of my code.
    Thank you in advance...
     
  2. XbNnX_507

    XbNnX_507 Active Member Licensed User

    Code:
    Do While some_test
         
    ' do stuff
    Loop
     
  3. Didier9

    Didier9 Active Member Licensed User

    Almost the same thing but not quite, which was the point of my request.
     
  4. Didier9

    Didier9 Active Member Licensed User

    In the first form, do_stuff is executed at least once even if the condition is false.
    In the second form, the do_stuff code is not executed at all if the condition is false.
    Turns out I tend to use the second form more.
     
  5. RandomCoder

    RandomCoder Well-Known Member Licensed User

    You can still achieve the same thing with a DO WHILE....
    Code:
    firstloop=False
    Do While (some_test AND firstloop)
         
    ' do stuff
         firstloop=True
    Loop
     
  6. MarkusR

    MarkusR Well-Known Member Licensed User

    Code:
    Sub Test
        
        
    Dim a As Int =0
            
        
    Do While 1=1
            
    Log("Hello")
            
    If a = 0 Then Exit
        
    Loop

        
    Log("End")
        
    End Sub
    favorite syntax wish
    Code:
    Do

     
    If x Then Exit Do
    Loop
     
  7. Didier9

    Didier9 Active Member Licensed User

    Of course I can do that but it's not what I would call elegant.
    Reason for the rant is I am just done converting a fairly large piece of VB 6.0 code that had a lot of these and I was not too happy about having to deal with that.

    On the other hand, B4J is just so much nicer in so many other aspects that I am still way ahead. The new code is probably half the size and twice as maintainable.
    Nevertheless, I shall complain...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice