Loops << Back



There are 3 types of standard loops in VDF Those are pretty standard in pretty much all common computer languages. However I do want to point out that you can mix and match different keywords in VDF to do something a little bit more.

To create an infinite loop (the old fashion/boring ways)

	Repeat
		// Looping indefinitely
	Until (False)
	
	While (True)
		// Looping indefinitely
	Loop

To create an infinite loop (mix and match)

	Repeat
		// Looping indefinitely
	Loop // "Until"
	
	Begin // "Repeat"
		// Looping indefinitely
	Loop
	
	Begin
		Break Begin // Jumps to the beginning of the control block, which causes infinite loop
	End
I complained about the Begin/Loop accident here. The compiler/runtime are still very happy with the code as of DataFlex 20.0 Alpha 2.

While/End loop

They are in quite a few places in the standard DF packages (as of DataFlex 20.0 Alpha 2). Here are some examples.
    While nb ge 0
        Get integer_value of obj nb to bobj
        Set GUIlocation of bobj to ht col
        Send Adjust_Logicals to bobj
        Move (col - swd - wd) to col
        Decrement nb
    End

For/Until

This type of loop has got to be my absolute favorite. You have both range check and an extra conditional check. There are quite a few places in the standard DataFlex packages.
    For iCount from 0 to iMax
        Get Data_Set_Server iCount to iDSO
        If not (Visited_state(iDSO)) ;
            Get Private.Valid_Structure of iDSO False to iRVal
    Until iRval

While/Until

It's pretty useless to do a While/Until loop since you are checking conditions back to back. However that compiler won't stop you from doing so.
	While (i<100)
		Increment i
	Until (i>=100)
Free Web Hosting