• 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: Back to Dynamic Records (Was: Re: interesting discovery)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Back to Dynamic Records (Was: Re: interesting discovery)


  • Subject: Re: Back to Dynamic Records (Was: Re: interesting discovery)
  • From: has <email@hidden>
  • Date: Tue, 4 Dec 2001 02:17:52 +0000

Greg Back wrote:

>on 12/3/01 10:19 AM, Neal A. Crocker at <email@hidden> wrote:
>
>> you can shorten that to:
>>
>> {{+class usrf;:{"hello", "goodbye"}}} as string as record
>> -- returns: {hello:"goodbye"}
>>
>> Neal
>
>This is great for my question about creating records during the running of a
>script. No offense to anyone (has or others),

[none taken]

>but this is a lot easier than
>the other methods for accomplishing what I want to accomplish. Does anyone
>(Chris N or others) know if this is expected behavior or what versions of
>Applescript this works in. If it is normal behavior, it will be a great step
>forward for my wordcount script

In fact, Chris has already mentioned that the {[record]} as string coercion
is a bug. (If it were to behave logically, it should either throw an error
or coerce the record to a list and then to a string.) You can enjoy it
while it lasts, if you wish; besides, you can always fall back to using
hashLib later if you have to.

Couple notes though: it's case sensitive (so for your wordcount handler
you'll need to lowercase words before adding them), and you'll still need
some way of getting values back out of the generated record on-the-fly.

The script below is based on an earlier post by Neal which seems to use a
"raw" reference to do the dirty work (is this right?). I'm not sure if this
trick would also be classed as a bug (Chris?).

I've refined Neal's code to avoid problems when compiling the script (the
custom record can only be compiled once). Unfortunately, this method also
uses "run script" - resulting in a non-trivial speed hit. (hashLib uses
Smile's "do script" so is much faster.)

OTOH, folks seem to be on a bit of a roll round here - maybe someone'll
figure out how to vanilla-ify this as well. (This would also take care of
Arthur's birthday present...;)

has

======================================================================

--initialise the script object (this avoids problems with editor
[NO-BREAK]recompiling/breaking the custom record)
on initGetVFRscript()
run script "script
on run {target, propname}
{class:reference,[LEFT-DOUBLE-CHEVRON]class
[NO-BREAK]form[RIGHT-DOUBLE-CHEVRON]:[LEFT-DOUBLE-CHEVRON]constant
[NO-BREAK]****usrp[RIGHT-DOUBLE-CHEVRON], [LEFT-DOUBLE-CHEVRON]class
[NO-BREAK]want[RIGHT-DOUBLE-CHEVRON]:[LEFT-DOUBLE-CHEVRON]class
[NO-BREAK]prop[RIGHT-DOUBLE-CHEVRON], [LEFT-DOUBLE-CHEVRON]class
[NO-BREAK]seld[RIGHT-DOUBLE-CHEVRON]:propname,
[NO-BREAK][LEFT-DOUBLE-CHEVRON]class from[RIGHT-DOUBLE-CHEVRON]:target
[NO-BREAK]}
end
end script"
end initGetVFRscript
property getVFRscript : initGetVFRscript()

--

on getValueFromRecord(theRecord, theLabel)
run script getVFRscript with parameters {theRecord, theLabel}
result's contents
end getValueFromRecord

getValueFromRecord({bar:2}, "bar")


======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]


  • Prev by Date: Re: interesting discovery (trying to get record labels as strings)
  • Next by Date: Re: <<event FNDRsope>> (WAS Re: Path to app ...)
  • Previous by thread: Running AppleScript with cron when not logged in?
  • Next by thread: Re: <<event FNDRsope>> (WAS Re: Path to app ...)
  • Index(es):
    • Date
    • Thread