• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Pass info from one to another script

Community Beginner ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

I wonder how to pass information from one script to another

(or save somewhere information).

I have one script where I enter information such as height, width etc.

and later I want to run a second script that would read the same information I have already entered.

For now, the only idea I have  is to create a text frame and read information from it

TOPICS
Scripting

Views

331

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

Valorous Hero , Mar 20, 2018 Mar 20, 2018

The most basic way is to simply write a text file and have your 2nd script always check for this text file.

Writing a text file is easy!

Check this out:

function writeFile(dest, contents){

  var f = File(dest);

  f.open('w');

  f.write(contents);

  f.close();

};

Votes

Translate

Translate
Adobe
Valorous Hero ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

The most basic way is to simply write a text file and have your 2nd script always check for this text file.

Writing a text file is easy!

Check this out:

function writeFile(dest, contents){

  var f = File(dest);

  f.open('w');

  f.write(contents);

  f.close();

};

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 ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Thanks!

Now I have a problem with reading all lines. And how can I choose which lines I want to load?

#target illustrator

var f = new File('~/Desktop/file.txt');

alert(readFile(f));

function readFile(f) {

     f.open('r');

     var line = f.readln();

     f.close();

     return line;

}

My txt file looks like this:

line1

line2

;ine3

line4

... etc.

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
Valorous Hero ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

You can read all the text and do what I do which is create an array by doing var myArray = myTextContent.split(/[\r\n]/g) via that regular expression.

Now you can reference each line like this : var myLine_4 = myArray[3];

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 ,
Mar 23, 2018 Mar 23, 2018

Copy link to clipboard

Copied

Please Help me, i gets the  answer: "undefined".

#target illustrator

var f =File.openDialog ("open file ");

alert(readFile(f));

function readFile(f) {

     f.open('r');

    

     var line = f.readln();

     var myArray = line.split(/[\r\n]/g);

     var myLine = myArray[3];

     f.close();

     return myLine ;

}

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
Valorous Hero ,
Mar 23, 2018 Mar 23, 2018

Copy link to clipboard

Copied

try this:

function readArrayFromFile(src){

  var f = File(dest);

  f.open('r');

  var contents = f.read();

  f.close();

  var allRowsArray = contents.split(/[\r\n]/g);

  return allRowsArray;

};

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 ,
Mar 23, 2018 Mar 23, 2018

Copy link to clipboard

Copied

LATEST

Thank you,

now it works

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