Uli Kusterer wrote:
>The only way we can truly work around this problem is if we allow
>scripter-defined chunk types. But that would make it much more verbose
>again:
>
> define delimiter schomp as "\"
> define delimiter schammel as "|"
> put schomp 5 of schammel 7 of "this\is\different|a\b\c|foo\bar|yeah\?"
>
>as opposed to:
>
> put item 5 delimited by "\" of item 7 delimited by "|" of
>"this\is\different|a\b\c|foo\bar|yeah\?"

If you use delimiter names that are speaking, it would get very readable:

  define delimiter pathItem as "/"
  define delimiter fileSuffixItem as "."

  put the last fileSuffixItem of the last pathItem of theFile into theSuffix

This seems to me even more readable than:

  put the last item delimited by "/" of the last item delimited by "."\
      of theFile into theSuffix


It would also be easy to expand to regexp delimiter (in the syntax 
Uli proposed in another mail):

  define delimiter block as "<" & some text & ">"

  put block 3 of theString into theBlock


BTW there are two dimensions to expand the term "item" to:

1. Items do not end on a single character, but on several in row:
      item 2 by "<br>" of "<brown>some</brown><br>text<br>string"
    returns "text"

2. Items that end on any of a set of delimiters:
      item 3 by "." or ";" of "this.is,a;test;string"
    returns "test"

The first problem can be solved with MetaTalk:

  function swap txt,x,y
    if y is empty then put "," into y
    if x is empty then put return into x
    put numToChar(0) into z
    replace x with z in txt
    replace y with x in txt
    replace z with y in txt
    return txt
  end swap

  put swap(item 2 of swap("<brown>some</brown><br>text<br>string","<br>")\
      ,"<br>") into theResult

Or
  repeat for each item x in swap(txt,"<br>")
    put swap(x,"<br>") into y
    ...


It would be easier to read if you could supply multiple character delimiters.

Also the second problem can be solved with MetaTalk:

  put "this.is,a;test;string" into txt
  replace ";" with "." of txt
  put item 3 by "." of txt into theResult


There are uses for both, but there are work arounds, so they should 
be not so high on the feature request list. A tree list is by far 
more important. And, Scott, if you implement the swap function, 
please leave these defaults or you'll break a lot of our code.


Regards!
     R�diger
--------------------------------------------------------------------
| Ruediger zu Dohna   GINIT GmbH   0721-96681-63    [EMAIL PROTECTED] |
| PGP-Fingerprint: F1 BF 9D 95 57 26 48 42 FE F8 E8 02 41 1A EE 3E |
--------------------------------------------------------------------

Reply via email to