Author Topic: Reset script  (Read 4881 times)

Offline bianry

  • PixInsight Enthusiast
  • **
  • Posts: 90
Reset script
« on: 2014 March 11 01:23:40 »
I am trying my hand on writing some scripts and per instructions I start by browsing the existing scripts.
If I compile and run one script it is OK. If I then try to open an other script and run that one it still runs the first script. Even if it is not open in the editor.

What am I missing?

r

Mats

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: Reset script
« Reply #1 on: 2014 March 11 02:32:07 »
There are multiple ways to run the scripts. 

I assume that you run them from the editor (f9 I think, although I am not in front of  PI).  The trick is that the Javascript environment stays alive between two executions in the editor.  So global variables of one execution remains in the next one.  For example if you make a typo like calling a function 'maim' instead of 'main', your script would call the 'main' defined in the previous script you executed.
The trick is to reset the Javascript engine before execution (somewhere on an execute menu in the script editor), in case of problem.
A good practice is also to initialize everything in a script and start it with "use strict"; as the first line. You may get better error messages.

This is only one of the bad things that may happen. It may be simpler. You may edit a file with the external editor and PI does not see it is modified.  Or you installed the scripts as a feature and did not refresh them

I propose that you first try writing a 'script' that just does a write on the console, save them in two files (with different texts), and see if this works well. This should.

-- bitli
(PS. I do not know your background, I hope I did not  give too obvious answers)
 


Offline bianry

  • PixInsight Enthusiast
  • **
  • Posts: 90
Re: Reset script
« Reply #2 on: 2014 March 11 03:31:04 »
Thank you. It was my mistake. Tried to run the same script in both files and wondered why they gave the same result. Duh!

I made some small changes to a DefectColumn script I found here. One question: is there a way to 'tombstone' a script such that it remembers all the last parameters that were given? Now I have to reload the defect-map every time.

[modified]
Ok. I found examples in the scripts. Will try to figure it out.

regards

Mats
« Last Edit: 2014 March 11 03:59:28 by bianry »

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Reset script
« Reply #3 on: 2014 March 21 01:20:38 »
Quote
A good practice is also to initialize everything in a script and start it with "use strict"; as the first line.

Alternatively (and probably a cleaner way IMO), you can enable/disable strict compiler mode with the pjsr command. Enter "pjsr" from the console to see the current state of all PJSR advanced options. Enter "help pjsr" for full information. You can enable strict mode with "pjsr -S+" and disable it with "pjsr -S-".
Juan Conejero
PixInsight Development Team
http://pixinsight.com/