08-10-2024, 10:43 AM
One place I find GOTO more than acceptable is when I have a long string of things to account for, and each has an unique process.
With the above, we find the first instance that handles the input we need to process, and then we skip all those other checks. If "Steve" just happens to be the first thing we check, we can skip 60 more IF checks that we know aren't going to ever process in that pass. Are there other ways to do it? Sure there are, but are any of them as simple, and easy to implement and understand, without having to wrack one's brain for how to minimize branching flows otherwise?
Code: (Select All)
IF Left$(user$,5) = "Steve" Then
...do stuff
GOTO end_check
END IF
IF Left$(user$,4) = "Jack" Then
...do stuff
GOTO end_check
END IF
IF Left$(user$,2) = "Jo" Then
...do stuff
GOTO end_check
END IF
...57 more unique cases to check and deal with...
end_check:
With the above, we find the first instance that handles the input we need to process, and then we skip all those other checks. If "Steve" just happens to be the first thing we check, we can skip 60 more IF checks that we know aren't going to ever process in that pass. Are there other ways to do it? Sure there are, but are any of them as simple, and easy to implement and understand, without having to wrack one's brain for how to minimize branching flows otherwise?