Wish I still long for Do Loop While()

Didier9

Well-Known Member
Licensed User
Longtime User
Is there any plan to add the common Visual Basic form of the Do Loop:
B4X:
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...
 

Didier9

Well-Known Member
Licensed User
Longtime User
Almost the same thing but not quite, which was the point of my request.
 

Didier9

Well-Known Member
Licensed User
Longtime 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.
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
You can still achieve the same thing with a DO WHILE....
B4X:
firstloop=False
Do While (some_test AND firstloop)
     ' do stuff
     firstloop=True
Loop
 

MarkusR

Well-Known Member
Licensed User
Longtime User
B4X:
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
B4X:
Do

 If x Then Exit Do
Loop
 

Didier9

Well-Known Member
Licensed User
Longtime 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...
 
Top