-always-load-scripts and included .js

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
tukuyomi
Full Member
Posts: 50
Joined: Mon Aug 09, 2010 6:15 pm

-always-load-scripts and included .js

Post by tukuyomi » Thu Sep 08, 2016 1:12 pm

Hi Developers !
tl; dr : How to reload included .js with the -always-load-scripts option?

The long version :
I'm writing a Skelton script that does all the init stuff / prototype and all those things I still don't fully understand :p

Inside the Skelton.prototype.beginEvent = function(), I include("child scripts.js"); that contains nothing but the actual drawing. (ala simple.js that includes simple_create.js, ...)
An example (Don't mind those variables and functions, they are defined in another include("post_ui.js"); and another script) :
Inside child_script.js

Code: Select all

getNewDrawing();

//Circle on Layer 0
addCircle( 0 , 0 , ray );

//Green Circles
addLayer( "Little Circles" , new RColor(0 , 255 , 0) );
addCircles( [
  [ ray , 0 , ray/9 ],
  [ -ray , 0 , ray/9 ],
  [ new RVector( 0 , -ray ) , ray/9 ],
  [ new RVector.createPolar( ray , Math.PI/2 ) , ray/9 ],
] );
// More stuff there

EAction.getGraphicsView().autoZoom();
Up to this point, all is working fine.

But when I modify the code in the included script, I always need to restart Qcad for the changes to take effect.
Do I need to add some magic code to reload the included script without reloading Qcad?
Do I need to change the very way I do my (I know :p) voodoo coding? If so, how? Ideas are welcome !

Thanks for reading !

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: -always-load-scripts and included .js

Post by andrew » Fri Sep 09, 2016 1:02 pm

The -always-load-scripts only affects the scripts directly tied to actions (through action.setScriptFile(...)).

I've extended this to includes for the next release.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”