Re: Using Akua Sweets' "decompose"
Re: Using Akua Sweets' "decompose"
- Subject: Re: Using Akua Sweets' "decompose"
- From: Andy Wylie <email@hidden>
- Date: Mon, 18 Jun 2001 15:55:09 +1200
on 18/6/01 6:25 am, Marc K. Myers at email@hidden wrote:
>
>
>
Andy Wylie wrote:
>
>
>
> on 18/6/01 3:40 am, Marc K. Myers at email@hidden wrote:
>
>
>
>> Andy Wylie wrote:
>
>>> on 17/6/01 10:59 pm, Marc K. Myers at email@hidden wrote:
>
>>>
>
>>>> set theParams to (decompose theParams by "% = %" & return)
>
>>>>
>
>>>> The missing piece of the puzzle (for me) was that the percent sign
>
>>>> serves to delimit multicharacter delimiters from other delimiters in the
>
>>>> "by" string.
>
>>>
>
>>> Mark, I'd be inclined to 'munge' spaces from the 'key' and decompose with a
>
>>> single delimiter to avoid problems.
>
>>
>
>> By this do you mean that you'd modify the input text to convert " = " to
>
>> "=" before using the "decompose" on it?
>
> Yes
>
>> If so, what's the advantage?
>
> If erronous spaces don't end up in your list they end up in it's items
>
> that's all...
>
>
>
> set the_list to "bal = Baldo
>
> agn =Agnes
>
> bnk= Binky
>
> whp = Whoppo"
>
>
>
> set the_list to decompose the_list by "% = %" & return
>
> -- {{"bal = Baldo"}, {"agn =Agnes"}, {"bnk= Binky"}, {"whp ",
>
> "Whoppo"}}
>
>
>
> set the_list to munge the_list from {space, tab} to ""
>
> set the_list to decompose the_list by "=" & return
>
> -- {{"bal", "Baldo"}, {"agn", "Agnes"}, {"bnk", "Binky"}, {"whp",
>
> "Whoppo"}}
>
>
>
Andy -
>
>
Thanks for the quick response. I had thought of doing something like
>
that but was blocked by the possibility that some of the items to be
>
extracted from the text would themselves contain spaces (i.e. "bbl =
>
Beetle Bailey") and would get corrupted by simply munging out all the
>
spaces in the input text. That left me with doing a loop to change " ="
>
to "=" and "= " to "=" until there were no more equals signs with
>
leading or trailing spaces. I was unaware of the "munge" command in
>
Akua Sweets. That makes it much easier:
>
>
set theText to "bbl = Beetle Bailey"
>
repeat
>
set outText to munge theText from {" =", "= "} to "="
>
if outText = theText then
>
set theText to outText
>
exit repeat
>
else
>
set theText to outText
>
end if
>
end repeat
>
--> "bbl=Beetle Bailey"
Mark, I really should have been asleep when I wrote that and take back what
I said about the delimiter, munge loops through it's feed list so no need
for a repeat, cool huh?
set theText to "bbl = Beetle Bailey"
set outText to munge theText from {" ", " ", " "} to " "
-- "bbl = Beetle Bailey"
_____________________________ Andy