• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

336

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Dec 29, 2016 Dec 29, 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

Votes

Translate

Translate
Mentor ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

Hi,

Broadly spoken...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

LATEST

Hi,

If various comps (apps) in use -- probably solution could be to store these data in txt files somewhere in network.

So instead of app.insert/extractLabel could be a custom functions savePresets(name, string) and importPresets(name).

Similar logic but using File.read() and File.write() methods.

Jarek

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines