Skip to main content
Known Participant
December 29, 2016
Answered

How can I move an array whose elements are arrays to and from a file??

  • December 29, 2016
  • 1 reply
  • 572 views

Basically I want to share the information that is in a set of arrays (which I certainly could put into a single array of arrays) between several InDesign documents. It seems that the simplest way to do this would involve writing a file containing all the information while in the first document and then reading it back while in the second document. I'm looking for help about how to structure the input/output process and the data and how to move the information back and forth. Thanks in advance for suggestions/solutions.

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

How about using app.insertLabel(key, string) where string is your array.toSource()?

You can call eval(app.extractLabel(key)) to return an array if needed and store it back regardless of which doc(s) is currently in use.

Jarek

1 reply

Jump_Over
Brainiac
December 29, 2016

Hi,

Broadly spoken...

Dick KainAuthor
Known Participant
December 29, 2016

I read that as you wanting more details. I have

var array1 = ()

...

var array7 = ()

They have been filled by the script taking user inputs and posting the input parameters in the arrays. The set of values array1 ... array7  defines the i'th preset for the script group. All the arrays are stored within the document where they were defined. I want to be able to use that group of presets while working on another document. I think the best way to do that is to put the group of settings (in other words, the array contents) into a file that can be read into a script (when the second document is open) and placed into that document's information so the presets will be available over there.

Dick KainAuthor
Known Participant
December 30, 2016

Hi,

How about using app.insertLabel(key, string) where string is your array.toSource()?

You can call eval(app.extractLabel(key)) to return an array if needed and store it back regardless of which doc(s) is currently in use.

Jarek


Thank you! I didn't appreciate that we could do this at the level of the app. That technique is how I have been keeping them within the document. But what could you do if you want to transfer the settings to another computer?