none
Text.GetLength command acting funny ?? RRS feed

  • Question

  • ZWQ561

    It seems here that Text.GetLength command is holding a result from a previous text and not updating with a new command execution .

    Or iam i missing something here... ?? 

    As is it finds the space character at location 19 ( the test starts at the end of the line and go's backwards ), then fails to find the other 2 remaining space characters..!!

    What im trying to do is find the last space character in the line as quickly as possible (why im working from the end of line, going back to front ).

    Also "cut" reports as value 18th position, when it should be 19th position !!!.



    dataline = "123 56789 ajdjfg32 4950" ' find all spaces ' space " " characters at 4, 10, 19 positions in dataline TestLen = Text.GetLength( dataline ) cut = TestLen try: PT = Text.GetSubText( dataline, 1, cut ) if Text.EndsWith(PT, 32 ) <> "True" Then If cut > 1 then TextWindow.WriteLine( PT +" " + ( cut ) ) cut = cut - 1 Goto try EndIf Else TextWindow.WriteLine( "space found at " + ( cut ) ) cut = cut - 1 Goto try EndIf
    Thursday, February 25, 2010 12:43 AM

Answers

  • if Text.EndsWith(PT, 32 ) <> "True" Then
    should be
    if Text.EndsWith(PT, Text.GetCharacter(32) ) <> "True" Then
    or
    if Text.EndsWith(PT, " ") <> "True" Then

    The primitive 32 is being converted to a number rather than a string (space character)
    • Marked as answer by Hot_Rod__ Thursday, February 25, 2010 5:06 AM
    Thursday, February 25, 2010 2:14 AM

All replies

  • if Text.EndsWith(PT, 32 ) <> "True" Then
    should be
    if Text.EndsWith(PT, Text.GetCharacter(32) ) <> "True" Then
    or
    if Text.EndsWith(PT, " ") <> "True" Then

    The primitive 32 is being converted to a number rather than a string (space character)
    • Marked as answer by Hot_Rod__ Thursday, February 25, 2010 5:06 AM
    Thursday, February 25, 2010 2:14 AM
  • Well dont you know, thanks a bunch for that.. it works now..

    As a side note i originally was using

    if Text.EndsWith(PT, " ") <> "True" Then

    but other problems at the time caused me to change it ( assumed it wasn't working) and in the process broke it ..

    I have been learning that it is much better to work on small portions of your code and test like crazy then move to the next problem.

    In years past i put together some great "spaghetti" programs :P , but with age, doing that is just to hard to keep it all straight and on track.

    Thanks again.
    Thursday, February 25, 2010 5:04 AM