Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Declaring Variables

$
0
0

This is a pretty basic question. How do you know when to declare a variable as new object, and when to simply declare it by naming it?

 

For example, here is a list of variables:

 

var textRange = new TextRange();

var pgf;

 

The textRange variable is declared as a new TextRange object. But the pgf variable is not declared as a new Pgf object. If you try to do this, ExtendScript says, "Pgf does not have a constructor."

 

How do you know if an object has a constructor? I see in the scripting guide that the TextRange object also lists TextRange as a method. That might be a clue, right?

 

Also, is it important to declare a variable as new object if it does have a constructor? For example, is there a difference between these two declarations:

 

var textRange;

var textRange = newTextRange();

 

Or is it more-or-less a preference?

 

Thanks.

 

Jason 


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>