[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: Self-referential problem



Reply to note from Carl Distefano  Sun, 22 Feb 2009
01:33:18 -0500

The guillemet wildcard is a neat solution to the problem of searching
for, or changing, a guillemet that's part of an XPL expression that
would otherwise be interpreted, not treated as part of the search
string.

(The solution, by the way, is different in Xy3. Instead of guillemet
wildcards, you'd use 3-byte guillemets in the search string:

'BCci_/:~/"/'XC

(The 3-byters, ":<" and ":>", are transformed into inert, SEarchable
1-byte guillemets, "~<" and "~>", when placed on the CMline after 'BC.)

Let's take the self-referential problem a step further, though. How
do you search for, or change, a wildcard guillemet or other wildcard
character? The answer is, you can't -- not, at least, with a SEarch
or CHange command. There's no way to "mention" a wildcard in a SEarch
or CHange command; a wildcard is always "used".

Of course, this being XyWrite, there's at least one way around the
problem. Here's a U2 frame that flags unsearchable characters:
wildcards (or strings including wildcards), and characters embedded
in 3-byte characters are the prime (only?) examples. (A solution for
Xy3 appears further below.) It operates from cursor position to end
of file. What it does is walk through the file, 1 KB at a time, and
parse the 1-KB chunk around the search string. If the parse is
productive (i.e., given , if %c equals
the search_string), the string is flagged as "found". (A simple test
for containment of the search string, by the way, is insufficient to
flag characters embedded in 3-byters. Hence the need to parse.)

Usage for the U2 routine is
 SEFU search_string
Usage for the Xy3 routine, SEFU3.PM, is similar (see below).

'%--_XYENCode_start--
{{5SEfu}}_Search_for_unsearchable_strings_(wildcards,_
chars_within_3-byte_chars)_[CLD_2/22/09]'^
~B
~>0~>
  'BXes_1'Q2
  'GT
  ~~>'DX
  ~
  ~'YD'CR
  ~<1~>
    ~+1024~>'DF
    'BXjmp_~'Q2
    ~<1~>'CR'CL
    ~'DF
    ~
    ~
    ~<>~~>
      ~
    ~
    ~+~~>'YD
    'BXjmp_~'Q2
    ~="+~~>
    ~~
  ~
  'BXjmp_~'Q2
  ~~
~
~~>~B'^
'^
'%--_XYENCode___end--

Same for XyWrite III+, v3.54 and later (tested in v3.58B):

'%--_XYENCode_start--
~'^
SEFU3.PM_for_XyWrite_III+_v3.54+_--_CLD_2/22/09'^
Search_for_unsearchable_strings_(chars_within_3-byte_chars,_etc.)'^
'^
Usage'.'^
RUN_SEFU3.PM_[search'-$tring]'^
Works_from_cursor_position_to_end_of_file'^
'^
~
~~>
~)<1~>
  ~~>~
~'GT
~~>
~'BCWorking...'GT
~'YD
~~>'CR
~==~~>
  ~'BCjmp_~'XC
  'BC'GT'DO'FF
  ~~
~
~+1024~>'DF'BCjmp_~'XC
'BC'GT'DF
~
~)<1~>'YD
  ~
~
~
~
~)<1~>
  ~
~
~<>~~>
  ~
~
~~>
~+@siz(~)~>'YD'BCjmp_~'XC
'BC'GT'DO'FF
~~'^
'%--_XYENCode___end--

The solution to the problem of changing "unCHangeable" strings is
left as an exercise, as math teachers like to say.

--
Carl Distefano
cld@xxxxxxxx