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

Definition of document variable

Community Beginner ,
Dec 18, 2016 Dec 18, 2016

Copy link to clipboard

Copied

Hi All,

how i can define variable to point to a document. is

var mySourceDocument = app.documents[0] ;

  correct?

it produce Result:undefined.

Regards

Saeed

TOPICS
Scripting

Views

392

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

Community Expert , Dec 18, 2016 Dec 18, 2016

Hi Saeed,

I suppose you are running this line of code with the ExtendScript Toolkit (ESTK) app and you are seeing this in the JavaScript Console after running:

Result: undefined

That does not mean that your variable mySourceDocument is undefined.

The whole script—that one line—is returning that to the ESTK console.

If you would add a second line like that:

var mySourceDocument = app.documents[0];

mySourceDocument

the result in the ESTK console—if a document is open—would be:

Result: [object Document]

The

...

Votes

Translate

Translate
Community Expert ,
Dec 18, 2016 Dec 18, 2016

Copy link to clipboard

Copied

Hi Saeed,

I suppose you are running this line of code with the ExtendScript Toolkit (ESTK) app and you are seeing this in the JavaScript Console after running:

Result: undefined

That does not mean that your variable mySourceDocument is undefined.

The whole script—that one line—is returning that to the ESTK console.

If you would add a second line like that:

var mySourceDocument = app.documents[0];

mySourceDocument

the result in the ESTK console—if a document is open—would be:

Result: [object Document]

The script would not return anything to the ESTK console if you would add e.g. exit() as second line:

var mySourceDocument = app.documents[0];

exit();

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
Community Beginner ,
Dec 19, 2016 Dec 19, 2016

Copy link to clipboard

Copied

LATEST

Laubender,

Thanks a lot! that is true. while waiting for the answer i tried to define the variable without var i.e

  1. mySourceDocument = app.documents[0]; 

and result in the ESTK console is

  1. Result: [object Document] 

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