Respond to this messageReturn to Index
Original Message
  • alternative
    • AlGoreIthm (no login)
      Posted Jul 19, 2012 8:17 PM

      This is a way to remove duplicate info in the table - but in this situation a space must be added to the end of each entry AND they must be set in a decreasing length order - PLUS there is no entry for 'me'.

      This reduces the program by 5 lines (all of which are data) but adds about 5 lines of programming. The first way is superior in my opinion, because it's simpler and the version below would need a special case to identify when the grammar calls for 'I' to be 'me'. Also, having more lines of data rather than code tends to be superior, since data never needs to be 'debugged'.

      DECLARE FUNCTION changeperson$ (tochange$)

      INPUT tochange$

      IF tochange$ <> "" THEN
      i$ = changeperson$(tochange$)
      PRINT i$
      END IF

      FUNCTION changeperson$ (tochange$)

      DIM s$(4)

      s$(1) = "myself yourself "
      s$(2) = "mine yours "
      s$(3) = "my your "
      s$(4) = "i you "

      tochange$ = LCASE$(LTRIM$(RTRIM$(tochange$))) + " "

      looper% = 1
      found% = 0


      IF INSTR(s$(looper%), tochange$) THEN found% = looper% ELSE looper% = looper% + 1

      LOOP UNTIL found% = looper% OR looper% = 5

      'PRINT found%: END

      IF found% THEN

      IF INSTR(s$(found%), tochange$) = 1 THEN
      b% = LEN(tochange$) + 1
      e% = LEN(s$(found%)) - LEN(tochange$)
      b% = 1
      e% = INSTR(s$(found%), " ") - 1
      END IF

      changed$ = MID$(s$(found%), b%, e%)
      PRINT changed$
      ELSE PRINT "NOT FOUND in table"
      END IF

    Your Name
    Message Title
    Message Text

     Copyright © 1999-2017 Network54. All rights reserved.   Terms of Use   Privacy Statement