Few questions on PJSR

robyx

Administrator
Staff member
Hi Juan,

wrapping up the whole presentation I have few questions:

1. I've found this thread (https://pixinsight.com/forum/index....rocess-improved-scripting-functionality.1399/) explaining the execution context. It says that in global context a script would never preset an interface. Is this a valid rule today? I ask because there are cases (like WBPP :)) where in global context the script just opens the dialog and reloading the instance parameters which is a behaviour I usually saw (and I intuitively expect)

2. In the Object Explorer, the listed objects have two kind of icons, a sphere and a pyramid. What's the difference between the two?

3. the dialog box initialization this.__base__ = Dialog; this.__base__(); I assume __base__ is internally used by PI or Qt or whoever since I didn't find any javascript keyword like __base__. Is it the way PI internally inspect the kind of Control your custom control inherits from?

thx
Robyx
 
Hi Roberto,

It says that in global context a script would never preset an interface. Is this a valid rule today?

Not at all. The thread you are referring to was posted back in 2009 (when I was young and all :) ). In that post I wrote the following:

- In the view or global contexts. This is the new instance mode of scripts. When a script is working as an instance, it must not create any graphical interface, besides (perhaps) a message box to inform the user about some critical condition. Instead, the script must perform "silently", according to the parameters it receives, just as all regular processes do in PixInsight. In instance mode, all script output should directed to the console exclusively.

I would not write the same today, of course. In a view context, it is true that a script should work just as binary processes usually do, avoiding any interactive interface. But this restriction is not at all applicable when a script runs as a global task, as WBPP does for example. Passing time is great to put everything in its real place :)

2. In the Object Explorer, the listed objects have two kind of icons, a sphere and a pyramid. What's the difference between the two?

Sphere icons indicate standard JavaScript objects (Date, Number, Math, etc). Pyramids indicate core PJSR objects (Control, SurfaceSpline, Graphics, ...). Processes defined by installed modules, which are all of them scriptable automatically, are shown with their corresponding process icons.

3. the dialog box initialization this.__base__ = Dialog; this.__base__(); I assume __base__ is internally used by PI or Qt or whoever since I didn't find any javascript keyword like __base__. Is it the way PI internally inspect the kind of Control your custom control inherits from?

This is just customary practice, not at all standard JavaScript. It is not something specific to PJSR, either. It's just a customary way to inherit all methods and properties from an existing object, such as Dialog in the example you've used.

When we have ECMAScript 6 available in PJSR (hopefully soon; as you know this is something very urgent), this won't be necessary because we'll be able to define classes with inheritance in a way very similar to C++:

JavaScript:
class Rectangle extends Shape
{
   constructor( id, x, y, width, height )
   {
      super( id, x, y );
      this.width = width;
      this.height = height;
   }
    
   ...
}
 
Back
Top