Is it possible coding button script in VSCode

Hi there,
I'm usually create a button , and then edit it, write some script in the script editor, is there a way to edit the code in VSCode directly rather than in the internal editor?

I'm currently edit code in VSCode, and then copy the code to the button in DOpus, it's not very convinient.

Thank you!
Rest Regards,

1 Like

You can edit script add-ins in any editor you want, and those can be called from buttons.

Scripts that are defined directly inside the buttons that run them can only be edited in the button editor.

Little question about VSCODE. When I click EDIT in the SCRIPT MANAGER, it opens another DIALOGUE (lets call it RESOURCES) containing the resources for the file I clicked on. It opens in VSCODE perfectly. :sunglasses:

My question is about saving. Do I need to constantly SAVE IN VSCODE, then go to the to RESOURCES dialogue and then SAVE THERE ALSO.

Is DOPUS polling the edited file to see if it was saved, automatically saving it ?

THX

No need to go back to Opus editor after editing in a third party editor as long as you keep the RESOURCES section at the end of your file.
EDIT: and yes, saving in external editor reloads the script for Opus to use tha last saved version (syntaxic errors, if any, will appear in the script log)

Not sure what you mean here. I don't have a RESOURCES section. I created everything kind of manually. Can I still add it after the fact, or should I make a brand new script and copy my code over?

I have to manually hit CTRL S or SAVE button in the SCRIPTS/RESOURCES dialogue

If your script contains UI elements (that you probably created with the designer), opening directly the .js or .vb file will get you your code and a resource section at the end.
See the code in the first post here : FAYT script : Dynamic Tab Groups

EDIT: I realize you probably don't have UI elements if you created all by yourself (IMHO using ui components is way easier with the resource designer). In that case : no RESOURCES section in your code and no need to copy back to the Opus editor (the one you call RESOURCES). Saving in VSCODE should be enough. That's what I do with sublime text, there's no reason it would be different with another text editor.

thx. No not using UI elements.
But I do not get AUTO SAVING. SO if anyone out there in the ether has ideas as to why, lemme know.

Happy new year !

no need to use save in VSCode, only need to save in the resource dialog

If you open the file directly with your external editor from its location on disk without opening the window from script manager, saving from external editor works.

That method means creating/editing dialogs and adding additional resources is more difficult.

I agree that dialog editing is way easier from designer.
I use this method only when no dialog creation/updating is necessary.
Once that is done, I can use it again (being careful to preserve the end of script RESOURCES section)

So - you must open DIRECTLY - I was always opening in the SCRIPT MANAGER WINDOW.

Question - how does DOPUS know that there was a change (i.e. SAVE)? I assume when you open DOPUS and its running, it has the ADDIN JScript in memory.

I just tried opening DIRECTLY - and DOPUS does not use the most recent version

It monitors the folder and will use the updated script. You'll see it in the logs.

You can configure that to use an external editor as well.

It does for me, and seems to be the case for lxp too : check again the script logs.
One case it won't : syntaxic errors (which would also display in script log), but this should invalidate the whole script as far as I remeber (away from computer, can't test right now)

Am i looking for special DOPUS script logs?

No, just put some logs in your script to hzlp you identify which version is called.

I already know exactly which version is called when I click button. Its the one in the ADDINS folder.

Steps

  1. DOPUS is already open
  2. Run the script in question to see log output.
  3. using VSCODE - open the the script direct from ADDINs folder, not from the SCRIPT MANAGER area.
  4. Edit the script and put log 'special log msg' at start of file to identify the one being changed in VSCODE. Save in VSCODE.
  5. Run the script again from DOPUS.
  6. I DO NOT see 'special log msg', which means the DOPUS did not 'catch' the just-edited script file.

I reviewed everything once more and by golly, i think its working !!!!!
Will test a few more times

ALL GOOD THNX :grinning: :smiley: :smile: :sunglasses: :nerd_face: :upside_down_face:

1 Like

Now, if you setup the external editor as VSCODE, it should also work if you try and edit from the "Resources window" you get from the script manager.
Do whatever suits you best.

On my side I have set-up a "project" in sublime text that exposes the whole add-ins folder, so it's easier to open directly from sublime text. I only use the window from script manager when I need the designer.
In that case, I have to be carefull to save in sublime text before opening the "resource window" to do dialog design, save there, then in sublime text, revert from disk to load the resources modifications, then keep on modifying there (after closing the "resources window" to avoid conflicts and errors).