Skip to main content
Inspiring
September 23, 2014
Answered

meaning of "undefined" in script

  • September 23, 2014
  • 2 replies
  • 569 views

Hi,

I am beginner to scripting. Generally, what does undefined mean in script. please explain in detail.

for example, in this script:

var myDocument = app.documents.add();

var myPageWidth = myDocument.documentPreferences.pageWidth;

var myPageHeight = myDocument.documentPreferences.pageHeight;

with(myDocument.pages.item(0)){

//Place guides at the margins of the page.

guides.add(undefined, {orientation:HorizontalOrVertical.vertical, <lb>

location:marginPreferences.left});

guides.add(undefined, {orientation:HorizontalOrVertical.vertical, <lb>

location:(myPageWidth - marginPreferences.right)});

guides.add(undefined, {orientation:HorizontalOrVertical.horizontal, <lb>

location:marginPreferences.top});

guides.add(undefined, {orientation:HorizontalOrVertical.horizontal, <lb>

location:(myPageHeight - marginPreferences.bottom)});

//Place a guide at the vertical center of the page.

guides.add(undefined, {orientation:HorizontalOrVertical.vertical, <lb>

location:(myPageWidth/2)});

//Place a guide at the horizontal center of the page.

guides.add(undefined, {orientation:HorizontalOrVertical.horizontal, <lb>

location:(myPageHeight/2)});

}

This topic has been closed for replies.
Correct answer Marc Autret

See also:

Values, Types, and Operators :: Eloquent JavaScript

2 replies

Marc Autret
Marc AutretCorrect answer
Legend
September 23, 2014
Math_Kay1Author
Inspiring
September 24, 2014

Hi Marc Autret,

Thank you so much for this link that u have given. It is elaborate and simple.

Jump_Over
Legend
September 23, 2014

Hi,

Imagine method has 2 optional parameters.

Alike move( [to:], [by:] ). Both use an array with x and y value but 1st set is coordinate and 2nd set is a distance.

If you want to specify 1st one and omit 2nd one ==> no problem - just omit it.

The problem is if you want to omit 1st one. In this case you have to set this parameter as "undefined" before describing a second one.

Jarek