• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reco Label Stringer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Reco Label Stringer (From: Mr Tea <email@hidden>)

  • Prev by Date: Re: dd: position of text
  • Next by Date: Re: Applescript with Eudora
  • Previous by thread: Re: Reco Label Stringer
  • Next by thread: Re: Owner/User Name in OSX
  • Index(es):
    • Date
    • Thread