Re: Reco Label Stringer
Re: Reco Label Stringer
- Subject: Re: Reco Label Stringer
- From: Andy Wylie <email@hidden>
- Date: Sun, 28 Apr 2002 11:51:27 +1200
on 28/4/02 8:51 AM +1200: has wrote:
>
Michael Sullivan wrote:
>
>
>> I couldn't find anything I recognised as Arthur's 'TID-based pseudo-hash
>
>> script' though you mentioned posting it once.
>
>
>
> I think he's referring to AssociativeLib which is on www.applemods.com,
>
> though from the noise Arthur made in response to one of the recent
>
> mentions, the existing version may be a bit under his current speed
>
> tweaking and/or error checking, or just plain elegant programming
>
> abilities.
>
>
Nope, not that one - it stores keys in a list, so is slower. (Unless it's
>
been redone since its original release.)
>
but that's what I was looking for though I expected Arthur had already done
recordWrecker from the plugs for your array and feigned disinterest, my
impetous was people bemoaning the fact records don't behave like lists.
-----------------
script recordWrecker
property someRecord : {}
property strungLabels : {}
property ick1 : {}
property count1 : {}
property shoo : (ASCII character 0)
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 strungLabels to {}
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 strungLabels to (its text items 5 thru itsEnd as
string)
end tell
end repeat
return strungLabels
end cleanLabels
to findValue(critter, someRecord)
script recX
property someRecord : {}
to doStuff(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 ""
set n to ((count1 - ((count2 / 2) - 1)) div 1)
return ((someRecord's every string)'s item n) as string
end doStuff
end script
tell recX to doStuff(someRecord)
end findValue
end script
on flatPairLists(labels, values)
set lst to {}
repeat with x from 1 to length of labels
set end of lst to item x of labels
set end of lst to item x of values
end repeat
return lst
end flatPairLists
on makeRecord(flatList)
set param to {<<class usrf>>:flatList}
run script "
on run (arg)
arg as record
end" with parameters param
end makeRecord
--test
set listA to {frog:"froggie", dog:"fido", cat:"kitty", |cane toad|:"dairy
queen", hamster:"hammy"}
tell recordWrecker to cleanLabels(listA)
makeRecord(flatPairLists(recordWrecker's strungLabels, listA's every text))
--------------------
this works fine thanks Arthur but compiling class usrf was troublesome.
Perhaps you can offer advice on scope has.
____________________________cheers 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.