• 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: list (form data) to Record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: list (form data) to Record


  • Subject: Re: list (form data) to Record
  • From: Daniel Shockley <email@hidden>
  • Date: Wed, 28 Feb 2001 21:48:45 -0800 (PST)

> Message: 8
> Date: Wed, 28 Feb 2001 10:24:54 -0800
> Subject: Re: Records
> From: Olof <email@hidden>
> To: <email@hidden>
>
> Here's the easiest way to do it using only the standard additions:
>
> __begin script__
>
> to usrf(theList)
> set n to {+class usrf;:theList}
> run script "
> to run (arg)
> arg as record
> end run " with parameters n
> end usrf
>
> usrf({"a", 1, "b", 2})
>
> __ end script__
>
> - Olof
>

Olof, that's a great script!
However, I tried it as follows and got a disappointing result - I'm not sure why:
------------ BEGIN
to listToRecord(theList)
set n to {+class usrf;:theList}
run script "
to run (arg)
arg as record
end run " with parameters n
end listToRecord

listToRecord({"firstName", "Dan", "lastName", "Shockley"})
-- returns {|firstName|:"Dan", |lastName|:"Shockley"}
--------------END

I've seen pipes around values/fields before when the variable is already defined, but this one
stumps me. I wonder if it happens somewhere in the run script section, which I don't quite
understand. If I change "firstName" to "fn" and "lastName" to "lstN" it works. However, if I try
to change "lastName" to "ln", I get the pipes around it: |ln|

Do you know why this is happening? When it does, I have to get the field value by calling the
property with the pipes around the name:
get |firstName| of the result

which is somewhat disappointing.

Thanks,


=====
Daniel A. Shockley
email@hidden
http://www.krioni.com

And now for a message from my sponsor... *grin*
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/


  • Prev by Date: Re: Records
  • Next by Date: Re: Repeat-Dialog-Error
  • Previous by thread: Re: Scripting Additions
  • Index(es):
    • Date
    • Thread