• 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: OSAX to Tokenize Record Field Names from List Items ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OSAX to Tokenize Record Field Names from List Items ???


  • Subject: Re: OSAX to Tokenize Record Field Names from List Items ???
  • From: Mark Alldritt <email@hidden>
  • Date: Sat, 23 Jun 2007 09:21:12 -0700
  • Thread-topic: OSAX to Tokenize Record Field Names from List Items ???

Hi,

> How might one go about the process of parsing a list, for instance:
>
> {"fSource", "PicName", "fObjStyle", "[Basic Graphics Frame]", "fWidth",
> "12p6", "fHeight", "9p3"}
>
> ... and dynamically build a record, such as:
>
> {fSource:"PicName", fObjStyle:"[Basic Graphics Frame]", fWidth:"12p6",
> fHeight:"9p3"}
>
> ... without having those field names predefined.
>
> In other words, I would like to dynamically tokenize each odd-indexed filed in
> the list and pair it with the following even-indexed value. Is this possible
> with some sort of OSAX?

I have a scripting addition that allows you to manipulate record properties
dynamically called List & Record Tools which makes things like this fairly
easy:

--    This code uses my List & Record Tools scripting addition
--
--    http://www.latenightsw.com/freeware/RecordTools/index.html
--

on makeRecordFromArray(fieldValuePairs)
    local propNames, propValues

    --  Split fieldValuePairs into two lists: a list of property names
    --  and a list of property values...
    set propNames to {}
    set propValues to {}
    repeat with i from 1 to length of fieldValuePairs
        if i mod 2 is 1 then -- odd
            set end of propNames to item i of fieldValuePairs
        else -- even
            set end of propValues to item i of fieldValuePairs
        end if
    end repeat

    --  Create the record using List & Record Tools...
    return set user property propNames to propValues in {}
end makeRecordFromArray

makeRecordFromArray({"fSource", "PicName", ¬
    "fObjStyle", "[Basic Graphics Frame]", ¬
    "fWidth", "12p6", ¬
    "fHeight", "9p3"})
--> {
--    |fSource|:"PicName",
--    |fObjStyle|:"[Basic Graphics Frame]",
--    |fWidth|:"12p6",
--    |fHeight|:"9p3"
--  }

Cheers
-Mark

------------------------------------------------------------------------
Mark Alldritt                      Late Night Software Ltd.
Phone: 250-380-1725                Script Debugger 4.0 - AppleScript IDE
WEB:  http://www.latenightsw.com/  FaceSpan 4.3 - AppleScript RAD
                                   Affrus 1.0 - Perl Debugging


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Scripting Interface Design
  • Next by Date: Re: OSAX to Tokenize Record Field Names from List Items ???
  • Previous by thread: RE: OSAX to Tokenize Record Field Names from List Items ???
  • Next by thread: RE: OSAX to Tokenize Record Field Names from List Items ???
  • Index(es):
    • Date
    • Thread