GoSub Return's
-
Imagine my horror to find the following code style employed in a body of code I've inherited (VBA, hopefully I'll be able to migrate it away).. I must say though, there's one VB6/VBA feature I stumbled across in code at work today that makes all these pale into insignificance for obfuscation potential. It's our old friend GoSub/Return.
Function MyFunction
' Do some stuff
GoSub CheckRoutine' Other Stuff GoTo TheEnd
CheckRoutine:
' More stuff
ReturnTheEnd:
' Cleanup
End Function
Refactoring this steaming pile's gonna be fun. (The original function is 250 lines, and oddly, it calls other functions/subs, as well as using GoSub to access "nested" functions). Last time I saw that pair of keywords actually used in a program dates back to my 2nd computer - the ZX Spectrum. Please reassure me that Microsoft had the good sense to remove these before the advent of VB.NET
-
Imagine my horror to find the following code style employed in a body of code I've inherited (VBA, hopefully I'll be able to migrate it away).. I must say though, there's one VB6/VBA feature I stumbled across in code at work today that makes all these pale into insignificance for obfuscation potential. It's our old friend GoSub/Return.
Function MyFunction
' Do some stuff
GoSub CheckRoutine' Other Stuff GoTo TheEnd
CheckRoutine:
' More stuff
ReturnTheEnd:
' Cleanup
End Function
Refactoring this steaming pile's gonna be fun. (The original function is 250 lines, and oddly, it calls other functions/subs, as well as using GoSub to access "nested" functions). Last time I saw that pair of keywords actually used in a program dates back to my 2nd computer - the ZX Spectrum. Please reassure me that Microsoft had the good sense to remove these before the advent of VB.NET
almost gone[^]: EndIf, GoSub, Let, Variant, and Wend are retained as keywords, although they are no longer used in Visual Basic .NET :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]
-
almost gone[^]: EndIf, GoSub, Let, Variant, and Wend are retained as keywords, although they are no longer used in Visual Basic .NET :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]
Yes, I checked that shortly after posting earlier. Hopefully I won't find similar treasures in the newer code base then. Same guy seems inordinately fond of empty true-parts of If statements:
If x = 3 Then
Else
' Statements here
End Ifand other horrors, I'll try and keep you posted.
-
Imagine my horror to find the following code style employed in a body of code I've inherited (VBA, hopefully I'll be able to migrate it away).. I must say though, there's one VB6/VBA feature I stumbled across in code at work today that makes all these pale into insignificance for obfuscation potential. It's our old friend GoSub/Return.
Function MyFunction
' Do some stuff
GoSub CheckRoutine' Other Stuff GoTo TheEnd
CheckRoutine:
' More stuff
ReturnTheEnd:
' Cleanup
End Function
Refactoring this steaming pile's gonna be fun. (The original function is 250 lines, and oddly, it calls other functions/subs, as well as using GoSub to access "nested" functions). Last time I saw that pair of keywords actually used in a program dates back to my 2nd computer - the ZX Spectrum. Please reassure me that Microsoft had the good sense to remove these before the advent of VB.NET
I think the last time I used a Gosub/Return was either on a Commodore 64, or maybe on VAX/VMS BASIC... either way, it was mid '80s.... In this day and age, even with VBA in mind, there is no reason to use that pair of keywords. Tim
-
Yes, I checked that shortly after posting earlier. Hopefully I won't find similar treasures in the newer code base then. Same guy seems inordinately fond of empty true-parts of If statements:
If x = 3 Then
Else
' Statements here
End Ifand other horrors, I'll try and keep you posted.
It's ugly, but will be optimised away.
Panic, Chaos, Destruction. My work here is done.
-
almost gone[^]: EndIf, GoSub, Let, Variant, and Wend are retained as keywords, although they are no longer used in Visual Basic .NET :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]
If you type Wend in Visual Studio in VB code it automatically replaces it with End While. I can't decide whether that's intended to be helpful (we'll fix that for you, sir) or whether it's a subtle nudge (learn the new syntax, dummy!). I must admit, I always rather liked the Let keyword. It seemed like such a polite way to code. I say, old chap, would you mind terribly letting a = b. Thanks awfully.