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

List of all scripts labels

Guest
Mar 10, 2017 Mar 10, 2017

Copy link to clipboard

Copied

Hi everyone,

Is it possible to have the list of all labels associated to a textframe ?

Example :

     txtfrm.insertLabel "key1", "value1"

     txtfrm.insertLabel "key2", "value2"

     txtfrm.insertLabel "key3", "value3"

     txtfrm.getAllLabels  --> "key1, key2, key3"

Thanks.

Cyril

TOPICS
Scripting

Views

1.1K

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 , Mar 10, 2017 Mar 10, 2017

var txtfrm = app.selection[0];

txtfrm.insertLabel ("key1", "value1")

     txtfrm.insertLabel ("key2", "value2")

     txtfrm.insertLabel ("key3", "value3")

var getLabels = function(item) {

  var f = File(Folder.desktop+"/"+item.id+".idms" ),

  x, a, o = {}, keys, n;

  if  ( !(item.exportFile instanceof Function) ) return;

  item.exportFile ( ExportFormat.INDESIGN_SNIPPET,  f );

  if ( !f.exists ) return;

  f.open("r");

  x = XML ( f.read() );

  f.close();

  f.remove();

  keys  = x..KeyValuePair;

  n = keys.len

...

Votes

Translate

Translate
People's Champ ,
Mar 10, 2017 Mar 10, 2017

Copy link to clipboard

Copied

var txtfrm = app.selection[0];

txtfrm.insertLabel ("key1", "value1")

     txtfrm.insertLabel ("key2", "value2")

     txtfrm.insertLabel ("key3", "value3")

var getLabels = function(item) {

  var f = File(Folder.desktop+"/"+item.id+".idms" ),

  x, a, o = {}, keys, n;

  if  ( !(item.exportFile instanceof Function) ) return;

  item.exportFile ( ExportFormat.INDESIGN_SNIPPET,  f );

  if ( !f.exists ) return;

  f.open("r");

  x = XML ( f.read() );

  f.close();

  f.remove();

  keys  = x..KeyValuePair;

  n = keys.length();

  if ( !n ) return;

  while ( n-- )  {

  o[String(keys.@Key)] = String(keys.@Value);

  }

  x = null;

  return o;

}

var labels = getLabels ( txtfrm );

alert ( labels? labels.toSource() : "None" );

Capture d’écran 2017-03-10 à 11.38.10.png

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
Guide ,
Mar 10, 2017 Mar 10, 2017

Copy link to clipboard

Copied

Ingenious! Very clever Loic.

P.

Edited to say.

Expensive in time. but still very clever.

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
Guest
Mar 10, 2017 Mar 10, 2017

Copy link to clipboard

Copied

Okay. Thank you.

I wil test it this afternoon.

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
Guest
Mar 13, 2017 Mar 13, 2017

Copy link to clipboard

Copied

LATEST

Perfect !

It works !

Thank you.

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