Scripting : Changes in include file requires modification in main script to be taken into account

If a "main" script uses one include file, any modification brought to the include file in a separate editor window (and saved) is not seen by the main script until you also save it (which requires a dummy update like adding and removing a whitespace).
Seen = taken into account at exec time, meaning it executes the code of the include file as it was the last time the main script was saved.
In itself, it is a bit annoying, yet manageable.

But there are 2 downsides/side-effects :
.opusinstall managment :
It propagates to the version referenced in the .opusinstall for the main script, should you create it. It only affects the version referenced in the exportkey.xml inside the .opusinstall, the include script itself is actually saved in its latest version.

seeing the include script from the main script editor :
If you try and open the include script from the main script editor (from left pane treeview), it always displays the first version opened in this instance of the editor (you need to close this editor and reopen it to view any changes). This means that if you edit the include script from another window, you don't see any changes made to the include script since starting to edit the main script.
Changes in executed code are taken into account if you "resave" the main script (as described at the beginning of this post), but visually the code seen in this editor (include script tab) is not updated.

editing the include script from the main script editor :
If you attempt to modify the code of the include script from the main script editor :

  • It doesn't reflect in the include script editor if it was opened before (close/reopen displays code properly).
  • There is some glitch with the red dot at the end of the include script name in the left pane treeview : it does not disappear when saving include script from the main script editor.

Sorry to report such issues that are probably not the top of the list things to fix.
The problem with include script not synchronised between multiple editors is kinda annoying because if you don't know it, it could lead to code loss if editing both files "in parallel".
Best thing would be to detect changes in source file by any of the editors and some kind of warning to allow you to refresh (or force refresh ??) ... like some editors do (sublime text for instance). Or disable include script editing from main script editor ("read-only" mode).

1 Like

Same here. When an included file is saved, the log shows the file being reloaded, but DOpus does not seem to look for any including files to process them as well. Apart from explicitly saving (or "touching") them, DOpus.ReloadScript() also makes DOpus "see". So as a workaround I made a user command that reloads all my scripts. Now if only I could remember to always use that command... :wink:

Come to think of it: I guess I could also automate the process using FSUtil.WatchChanges and OnFilesystemChange. :thinking:

1 Like

@Leo / @Jon : any thought on this ?
As said, not very urgent from my pov as long as we are aware of the issue/limitation. Actions/workarounds can be taken to deal with it.

It's on our list but not looked at it yet.

2 Likes

Thanks for this idea.
As a workaround : I made the some of the scripts using include files autoreload themselves in the commands entry points (e.g. the cmd.method pointed to in the AddCommands).

function OnDoWhateverThisCommandIsAbout(scriptCmdData) {
    DOpus.ReloadScript(Script.file);
    // ....

This should be (mostly) resolved in 13.11.3.

2 Likes