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

save user input for next script execution

New Here ,
Sep 01, 2018 Sep 01, 2018

Copy link to clipboard

Copied

Hi!

I just started with writing Scripts for InDesign, and was wondering, if it is possible to save the values the User entered in my Dialog and use them as defaults when he executes the script next time?

It would be nice, if you could save them in the indd-file he was using the script, so when he is opening the indd-file again his defaults still persist.

But its also ok if the values only persist for the duration of one session.

Do you have any advices?

Thanks!

TOPICS
Scripting

Views

1.9K

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

People's Champ , Sep 01, 2018 Sep 01, 2018

Sure it's possible. The simplest way to do it is to write a document label:

myDocument.insetLabel("Animal Selected", "Cow");

This can then be extracted as so:

myDocument.extractLabel("Animal Selected");

The beauty is that document labels are stored alongside the document, so any time the user opens that document, their choices can be read.

It is also possible to store a label in the application itself -- in the same way as above.

So it's up to you to decide whether you want the user's choices to be do

...

Votes

Translate

Translate
People's Champ ,
Sep 01, 2018 Sep 01, 2018

Copy link to clipboard

Copied

Sure it's possible. The simplest way to do it is to write a document label:

myDocument.insetLabel("Animal Selected", "Cow");

This can then be extracted as so:

myDocument.extractLabel("Animal Selected");

The beauty is that document labels are stored alongside the document, so any time the user opens that document, their choices can be read.

It is also possible to store a label in the application itself -- in the same way as above.

So it's up to you to decide whether you want the user's choices to be document-specific or application-specific.

Ariel

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
New Here ,
Sep 04, 2018 Sep 04, 2018

Copy link to clipboard

Copied

Brilliant! I will test this!

Are there any naming convention i should consider, so i don't interfere with other scripts or indesign itself?

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 Expert ,
Sep 04, 2018 Sep 04, 2018

Copy link to clipboard

Copied

LATEST

Hi elhodel ,

there is one key word with insertLabel() you should be aware of.
And that is the string "Label".

With that you do a "Script Label" entry the user is able to see if done on a regular item on the page like a rectangle or a text frame.

Before running the snippet just select a rectangle on the page:

app.selection[0].insertLabel( "Label" , "Message not hidden anymore from the UI.");

app.selection[0].label // Returns string "Message not hidden anymore from the UI."

Open the Script Label Panel to inspect the value of property "label" of the selected rectangle:

ScriptLabelSample.png

Regards,
Uwe

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