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

Re: [Clip] Extended Character Search

Expand Messages
  • Hugo Paulissen
    What I would like to do is enter in to a textbox the ASCII character ... Hi Mike, Best of luck to you all in 2006... ; ONE CHARACTER ^!Find
    Message 1 of 3 , Jan 3, 2006
    • 0 Attachment
      What I would like to do is enter in to a textbox the ASCII character

      >>value (or a range of values) and then get NTB to recursively search
      >>through the entire document for characters that match the ASCII value.
      >>Having hada look through the commands available (and a suggestion from
      >>the NTB Basic list) it was suggested that the following commands
      >>should work:
      >>
      >>^$CharToDec(Character)$
      >>^!Find "SearchText"
      >>
      >>How would I wrap this up in the outline above??
      >>
      >>Many thanks
      >>
      >>mike
      >>
      >>
      Hi Mike,

      Best of luck to you all in 2006...

      ; ONE CHARACTER
      ^!Find "^$DecToChar(^?[Enter ASCII code=])$" W

      The above works if you ant to find a single character. Just hit F3 to
      repeat the search. You can do the same (F3) if you use the following
      construction. For testing purposes I've already filled in the range
      (97-100), but if you leave out the numbers after the equal signs you can
      fill in your own range. Or you jjust type over them...
      You may have to adjust the find-options, but the R stands for Regular
      Expression. What is searched for in this example is (a|b|c|d), which
      stands for look for a, b c or d. With a simple find instruction you can
      not see or highlight all of the matches, but you could mimic that by
      using the replace-line in this clip. It is now commented, but what it
      would do is surround all a, b, c and d's with *. For larger documents
      this could be problematic... so use with care.

      I've had some problems with the array, as others have noticed before,
      that's why it is "prefilled" now.

      This should get you started...

      ; RANGE OF CHARACTERS
      ^!CLEARVARIABLES
      ^!Set %START%=^?[Start of ASCII-range=97]
      ^!Set %END%=^?[End of ASCII-range=100]
      ^!Set %NUMBERofVALUES%=^$Calc(^%END%-^%START%+1)$
      ^!Set %COUNTER%=1
      ^!SetListDelimiter |
      ^!SetArray %VALUE%="^$StrFill(x|;^$Calc(^%END%-^%START%)$)$"
      :ARRAYFILLER
      ^!IF ^%COUNTER%>^%NUMBERofVALUES% FINDNOW
      ^!SetARRAY %VALUE^%COUNTER%%=^$DecToChar(^%START%)$
      ^!INC %COUNTER%
      ^!INC %START%
      ^!GoTo ARRAYFILLER
      :FINDNOW
      ;^!REPLACE "{(^%VALUE%)}" >> "*\1*" RAW
      ;or
      ^!Find "(^%VALUE%)" R

      Hugo
    Your message has been successfully submitted and would be delivered to recipients shortly.