Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. GoSub Return's

GoSub Return's

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharp
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rob Grainger
    wrote on last edited by
    #1

    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
    Return

    TheEnd:

    ' 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

    L T 2 Replies Last reply
    0
    • R Rob Grainger

      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
      Return

      TheEnd:

      ' 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

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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]


      R D 2 Replies Last reply
      0
      • L Luc Pattyn

        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]


        R Offline
        R Offline
        Rob Grainger
        wrote on last edited by
        #3

        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 If

        and other horrors, I'll try and keep you posted.

        N 1 Reply Last reply
        0
        • R Rob Grainger

          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
          Return

          TheEnd:

          ' 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

          T Offline
          T Offline
          Tim Carmichael
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • R Rob Grainger

            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 If

            and other horrors, I'll try and keep you posted.

            N Offline
            N Offline
            Nagy Vilmos
            wrote on last edited by
            #5

            It's ugly, but will be optimised away.


            Panic, Chaos, Destruction. My work here is done.

            1 Reply Last reply
            0
            • L Luc Pattyn

              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]


              D Offline
              D Offline
              David Skelly
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups