Re: Reco Label Stringer
Re: Reco Label Stringer
- Subject: Re: Reco Label Stringer
- From: Andy Wylie <email@hidden>
- Date: Thu, 25 Apr 2002 22:50:46 +1200
on 25/4/02 8:59 PM +1200: Mr Tea wrote:
>
This from Andy Wylie - dated 25/4/02 07.04 am:
>
All that label and string stuff looks rather interesting and useful, Andy.
>
Could you focus my attention a bit by saying a little more about the core
>
principles that you were demonstrating?
>
hmm, I'm not sure what they might be. It's a means (I've not seen before) to
an convenient end and offers acceptable performance so it seems kinda handy.
Here's a modular version you may find useful
----------------
property listA : {frog:"froggie", dog:"fido", cat:"kitty", |cane
toad|:"dairy queen", hamster:"hammy"}
script labelCleaner
property someRecord : {}
property strungLabel : {}
property ick1 : {}
property count1 : {}
to cleanLabels(someRecord)
set ick1 to ({someRecord} as string)
set AppleScript's text item delimiters to {"TEXT"}
set count1 to count someRecord
set loopCount to (count1 * 2)
set ick2 to ick1's text items 2 thru loopCount
set AppleScript's text item delimiters to ""
set {strungLabel, shoo} to {{}, (ASCII character 0)}
repeat with n from 1 to loopCount by 2
tell (ick2's item n)
if (its text item -1) = shoo then
set itsEnd to -2
else
set itsEnd to -1
end if
set end of strungLabel to (its text items 5 thru itsEnd as
string)
end tell
end repeat
return strungLabel
end cleanLabels
to findValue(critter, someRecord)
set AppleScript's text item delimiters to {critter}
set thisCritter to ick1's text item -1
set AppleScript's text item delimiters to {"TEXT"}
set count2 to count (thisCritter's text items)
set AppleScript's text item delimiters to ""
return (someRecord's every string)'s item (round (count1 - ((count2
/ 2) - 1)) rounding down)
end findValue
end script
tell labelCleaner to cleanLabels(listA)
set critter to (choose from list (result))'s item 1
tell labelCleaner to findValue(critter, listA)
say "hello " & result
----------------
>
I didn't quite get why 'cane toad' had those neither-forward-nor-back
>
slashes around it (what the heck are they called, anyway?).
>
Cane toads are very toxic; They're pipes, uppercase backslash on my keyboard
used to allow fancy names (space there :) for variables.
>
I'm particularly interested in labels and strings at the moment because I'm
>
going on holiday soon and need to get some for my luggage.
>
again already? I'm going to write myself a holiday in AS .
_____________________________ Andy
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.