a script to build scripts?

This should be simple - I want to go through an 8-page InDesign document which has 9 images on each page, and get the page name, polygon id and geometric bounds for all images. I want the values returned in a key value list, like so:

{pagename:“1”,itspolygons:{theID:111,thebounds:{321321,65465,321321,88878}}}, etc …

I know how to extract this information from the document, but I’m having trouble writing a script to put all this data into the above format. If anyone can suggest a syntax for this I can plug in the guts of the “tell Indesign” block …

thanks a million!

Applescript records (key value lists) are handy, but difficult to work with. They don’t handle anything like an array does. I’ve seen some tricks parsing error messages or using the pipe character around variables to get around limitations (never could understand that), but I usually build them the hard way:

set recordTemplate to {pagename:"", itspolygons:""}
set recordTemplate2 to {theID:"", thebounds:""}

set recordTemplate2's theID to 111
set recordTemplate2's thebounds to {321321, 65465, 321321, 88878}

set recordTemplate's pagename to "1"
set recordTemplate's itspolygons to recordTemplate2

return recordTemplate
-->{pagename:"1", itspolygons:{theID:111, thebounds:{321321, 65465, 321321, 88878}}}

You’ll have to pre-label all keys and build an empty record, and account for any keys that contain a record itself and build those, too. Then their values can be set as above.