Re: Snarfing Text between Variables
Re: Snarfing Text between Variables
- Subject: Re: Snarfing Text between Variables
- From: Xandra Lee <email@hidden>
- Date: Sat, 10 Mar 2001 19:19:55 -0500
Bless You!!
I can't tell you how often this situation has arisen, and I've avoided
dealing with it.
I've been using your fabulous OSAX since I began scripting, and hadn't
realized that "pick strings" could handle this.
Alixandra
>
At 08:40 -0500 03/09/2001, Xandra Lee wrote:
>
>2. 3rd party OSAXen OK
>
>2. Once text is isolated, I'll do some parsing on that text, then replace
>
>it with parsed version.
>
>
Using "MT Pick strings" in Tanaka's osax 2.0, the following script does
>
what you want.
>
>
set myData to "YadaYadayYada
>
TS1
>
Tanaka
>
TS2
>
YadaYadayYada
>
YadaYadayYada
>
TS1
>
Motoyuki
>
TS2
etc....
>
>
>
--- Script ---
>
>
on myParser(myText)
>
set tStr1 to "TS1" & return
>
set tStr2 to return & "TS2"
>
>
set xL to MT Pick Strings myText start with tStr1 end with tStr2 with
>
trimming
>
>
repeat with thisItem in xL
>
-- parsing
>
set newItem to revCase(thisItem)
>
-- replacing
>
set myText to MT Replace myText search (tStr1 & thisItem & tStr2)
>
replace (tStr1 & newItem & tStr2) with only first hit
>
end repeat
>
end myParser
>
>
on revCase(myText)
>
set myText to characters of myText
>
repeat with thisChar in myText
>
set x to ASCII number thisChar
>
if x > 96 then
>
set x to x - 32
>
else
>
set x to x + 32
>
end if
>
set contents of thisChar to ASCII character x
>
end repeat
>
return myText as string
>
end revCase
>
>
>
Hope this helps.
>
>
==============================================================
>
Motoyuki Tanaka Fukui Prefectural University
>
email@hidden Faculty of Economics
>
http://mtlab.ecn.fpu.ac.jp/
Alixandra Leigh
AceDesign
email@hidden
------------------------------------------
Furniture:
><
http://home.rochester.rr.com/alexleighs/furniture/furniture.htm>
Renderings:
><
http://home.rochester.rr.com/alexleighs/interiors/interiors.htm>