Autorefresh Loaded Scripts

  • When using an external script that's been loaded in could you make it so that the script is automatically refreshed when the compile button is clicked?

  • Can you elaborate on this? When you hit compile, it should already reload all external files...

  • If the file is added as an include it seems to work fine but it's when I've loaded a file from the right-click context menu it doesn't reload on compile. Also I noticed a strange thing, if I load a file that only contains this line Console.print("Hello World"); it will load that line of code multiple times. I've made a little video to demonstrate the issue, and also show it not reloading. It seems that each time I click compile it appends the file to the what's already in the editor.

  • Ah OK I see what you mean. I initially wrote the load script from file function for backup purposes, not for doing actual development with it. However I know there are some better code editors around (like Sublime or VS Code) so if it vastly increases your workflow I could think about it.

    I'll take a look at the bug in the video, seems something weird going on...

  • Yeah the HISE editor is great for debugging and protyping. I'm doing 90% of my coding in Sublime and either using a JS include or copying and pasting it into the appropriate callbacks. Being able to load it directly from external files would really speed up getting the code into the other callbacks.

  • But then I'd need to disable the editor in HISE for loaded scripts (just like KONTAKT does IIRC) which would basically break the current functionality.

    If I don't do that, any change you make in the HISE editor will be discarded when you recompile.

    But I agree that people should be using their code editor to fit in their workflow. I'll think of something...

  • Yes that's what Kontakt does, it locks you out of the editor. What about if it worked both ways so that changes made in HISE updated the external file when you hit compile? Although I suppose that might be an issue while it's still open in another editor if the editor doesn't refresh.

  • There is no way to determine whether it should reload the file or save it to disk when compiling, so it does make sense to lock it.

  • Alright, I took a look at the bug in the video. The problem is that scripts that are loaded this way into HISE need to be valid ScriptProcessor scripts with every callback defined. The minimal working example is this (just export a empty script and you'll get it):

    function onNoteOn()
    function onNoteOff()
    function onController()
    function onTimer()
    function onControl(number, value)

    Internally HISE splits up the file and puts the callbacks into their dedicated tabs (with everything before the onNoteOn callback in the onInit tab. But if they are not defined it goes nuts and does something weird (like you encountered in the video). I added a safe check that validates the script file and prints out a error message.

    However, there are actually only two places where things can get messy and that is the onInit callback with its endless JSON definitions and the monstrous switch statement in the onControl callback for bigger projects. This is why I added the include() method to outsource these parts into externally editable files. The other callbacks should not exceed a few lines of code and therefore don't need the extra workflow features of a dedicated code editor IMHO.

  • Ah that's good to know. Having all the callbacks in one main file will be good and then other functions can go into external files.

Log in to reply