Loading ...
Sorry, an error occurred while loading the content.

Re: Getting a particular word in a string

Expand Messages
  • Roy Herring
    Here is a clip that will parse a line into words (seperated by one or more spaces) and allow any word to be addressed by its position. It is based on Hugo s
    Message 1 of 3 , Feb 26, 2004
    • 0 Attachment
      Here is a clip that will parse a line into words (seperated by one or more spaces) and allow
      any word to be addressed by its position.
      It is based on Hugo's and Alec's suggestions.

      Thanks all,
      Roy

      ^!Set %Line%=1 2 3 4 5
      :Loop
      ; Remove adjacent spaces
      ^!Set %Z%=^$StrPos(" ";^%Line%;False)$
      ^!If ^%Z% <> 0 ^!Set %Line%=^$StrReplace(" ";" ";"^%Line%";False;False)$
      ^!If ^%Z% <> 0 ^!Goto Loop
      ; Parse line by words and select any word by position
      ^!SetListDelimiter " "
      ^!SetArray %LineWords%=^$StrTrim(^%Line%)$
      ^!INFO LineWords has ^%LineWords0% words; word 3 = ^%LineWords3%


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.