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. Return of an old friend

Return of an old friend

Scheduled Pinned Locked Moved The Weird and The Wonderful
tutorialannouncement
7 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

    I know I posted an example of this a while ago, but here's another classic example, and I thought some of the other bits in this snippet may amuse you ...

    For j = 1 To k
        char = UCase(Mid$(myField, j, 1))
    
        If InStr(delims, char) <> 0 Then
            If i <> j Then
                buffer = Mid$(myField, i, j - i)
                GoSub addIndex                      ' Nooooooooooooooooooooooooooooooooooooooo
            End If
            i = j + 1
        End If
    Next j
    
    If i <> j Then
        buffer = Mid$(myField, i, j - i)
        GoSub addIndex
    End If
    

    a bit later in the same routine...

    addIndex:

    If IsNull(buffer) Then Return
    buffer = Left$(Trim$(buffer), 20)
    
    If Len(buffer) = 0 Then Return
    wordnum = libWordNo(Trim(utilRemoveCrap(buffer)))
    
    If wordnum = 0 Then Return
    If InStr(wordsNow, ";" & CStr(wordnum) & ";") = 0 Then
        wordsNow = wordsNow & CStr(wordnum) & ";"
    End If
    
    If InStr(wordsThen, ";" & CStr(wordnum) & ";") <> 0 Then Return
    
    retSet.AddNew
    retSet!\[AccountNumber\] = recSet!\[AccountNumber\]
    retSet!\[recordNumber\] = recNum
    retSet!\[wordNo\] = wordnum
    retSet.Update
    Return
    

    I should also mention that there's a variable in the same routine called wordNo, and one called wordNum. Classy stuff. That dull thudding you can hear in the distance is my head banging against the desk.

    C R 2 Replies Last reply
    0
    • R Rob Grainger

      I know I posted an example of this a while ago, but here's another classic example, and I thought some of the other bits in this snippet may amuse you ...

      For j = 1 To k
          char = UCase(Mid$(myField, j, 1))
      
          If InStr(delims, char) <> 0 Then
              If i <> j Then
                  buffer = Mid$(myField, i, j - i)
                  GoSub addIndex                      ' Nooooooooooooooooooooooooooooooooooooooo
              End If
              i = j + 1
          End If
      Next j
      
      If i <> j Then
          buffer = Mid$(myField, i, j - i)
          GoSub addIndex
      End If
      

      a bit later in the same routine...

      addIndex:

      If IsNull(buffer) Then Return
      buffer = Left$(Trim$(buffer), 20)
      
      If Len(buffer) = 0 Then Return
      wordnum = libWordNo(Trim(utilRemoveCrap(buffer)))
      
      If wordnum = 0 Then Return
      If InStr(wordsNow, ";" & CStr(wordnum) & ";") = 0 Then
          wordsNow = wordsNow & CStr(wordnum) & ";"
      End If
      
      If InStr(wordsThen, ";" & CStr(wordnum) & ";") <> 0 Then Return
      
      retSet.AddNew
      retSet!\[AccountNumber\] = recSet!\[AccountNumber\]
      retSet!\[recordNumber\] = recNum
      retSet!\[wordNo\] = wordnum
      retSet.Update
      Return
      

      I should also mention that there's a variable in the same routine called wordNo, and one called wordNum. Classy stuff. That dull thudding you can hear in the distance is my head banging against the desk.

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      wordNo is probably a boolean. If the buffer contents are an actual word, then wordNo contains false. But if the buffer contetns are not a word, then wordNo contains true. wordNum is what happens to you after reading all this code. My brain is now num(b). :cool:

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

      1 Reply Last reply
      0
      • R Rob Grainger

        I know I posted an example of this a while ago, but here's another classic example, and I thought some of the other bits in this snippet may amuse you ...

        For j = 1 To k
            char = UCase(Mid$(myField, j, 1))
        
            If InStr(delims, char) <> 0 Then
                If i <> j Then
                    buffer = Mid$(myField, i, j - i)
                    GoSub addIndex                      ' Nooooooooooooooooooooooooooooooooooooooo
                End If
                i = j + 1
            End If
        Next j
        
        If i <> j Then
            buffer = Mid$(myField, i, j - i)
            GoSub addIndex
        End If
        

        a bit later in the same routine...

        addIndex:

        If IsNull(buffer) Then Return
        buffer = Left$(Trim$(buffer), 20)
        
        If Len(buffer) = 0 Then Return
        wordnum = libWordNo(Trim(utilRemoveCrap(buffer)))
        
        If wordnum = 0 Then Return
        If InStr(wordsNow, ";" & CStr(wordnum) & ";") = 0 Then
            wordsNow = wordsNow & CStr(wordnum) & ";"
        End If
        
        If InStr(wordsThen, ";" & CStr(wordnum) & ";") <> 0 Then Return
        
        retSet.AddNew
        retSet!\[AccountNumber\] = recSet!\[AccountNumber\]
        retSet!\[recordNumber\] = recNum
        retSet!\[wordNo\] = wordnum
        retSet.Update
        Return
        

        I should also mention that there's a variable in the same routine called wordNo, and one called wordNum. Classy stuff. That dull thudding you can hear in the distance is my head banging against the desk.

        R Offline
        R Offline
        Richard A Dalton
        wrote on last edited by
        #3

        I've devised a new technique for dealing with this kind of code. When el-coder-loco is at lunch, you sneak over and change some tiny part of the code. A plus to a minus, a True to a False, something small. Then they spend the next six months trying to debug the tangled mess that they've created. Keeping them out of your way. -Rd

        Hit any user to continue.

        S _ R 3 Replies Last reply
        0
        • R Richard A Dalton

          I've devised a new technique for dealing with this kind of code. When el-coder-loco is at lunch, you sneak over and change some tiny part of the code. A plus to a minus, a True to a False, something small. Then they spend the next six months trying to debug the tangled mess that they've created. Keeping them out of your way. -Rd

          Hit any user to continue.

          S Offline
          S Offline
          Sauro Viti
          wrote on last edited by
          #4

          Wow! A fantastic tecnique! :thumbsup:

          1 Reply Last reply
          0
          • R Richard A Dalton

            I've devised a new technique for dealing with this kind of code. When el-coder-loco is at lunch, you sneak over and change some tiny part of the code. A plus to a minus, a True to a False, something small. Then they spend the next six months trying to debug the tangled mess that they've created. Keeping them out of your way. -Rd

            Hit any user to continue.

            _ Offline
            _ Offline
            _Erik_
            wrote on last edited by
            #5

            You're a genius!!

            1 Reply Last reply
            0
            • R Richard A Dalton

              I've devised a new technique for dealing with this kind of code. When el-coder-loco is at lunch, you sneak over and change some tiny part of the code. A plus to a minus, a True to a False, something small. Then they spend the next six months trying to debug the tangled mess that they've created. Keeping them out of your way. -Rd

              Hit any user to continue.

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

              A great suggestion, but as he retired a while ago... At least I have the good sense to clear up after me

              R 1 Reply Last reply
              0
              • R Rob Grainger

                A great suggestion, but as he retired a while ago... At least I have the good sense to clear up after me

                R Offline
                R Offline
                Richard A Dalton
                wrote on last edited by
                #7

                Rob Grainger wrote:

                but as he retired a while ago...

                Let that not be an obstacle. A banana in a tailpipe can give a guy many days of debugging fun. Childish? perhaps, but you'll feel better. -Rd

                Hit any user to continue.

                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