DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Modify the default VBS script

Hi

Every time I start a VBS script, I start with typing a plethora of Dims, such as

Dim oMyChn, oMyGroupIn, oMyGroupOut, oMyGod, i,j,k,l,m

etc.

This is, because the way my script design habits are such that I will most probably construct my algorithms along this objects.

Is there a way to have this as Default, instead of the Default

'-------------------------------------------------------------------------------

'-- VBS-Script-Datei

'-- Neu erstellt am 26.04.2018 14:10:32

'-- Ersteller:

'-- Kommentar:

'-------------------------------------------------------------------------------

Option Explicit 'Erzwingt die explizite Deklaration aller Variablen in einem Script.

?

 

Thank you for a hint

Michael

 

0 Kudos
Message 1 of 3
(2,892 Views)

Hi Nimic,

 

Yes, you can save a default file.

Go to SCRIPT, then type whatever you need in your VBS.

Select File > Save Workspace As... and save the WSP file wherever you want or your PC or server.

Save the VBS file you edited too as Template.vbs for example.

In Settings > DIAdem Settings > Script select that said WSP file as Default File. Close the settings.

In Settings > Save As save the modified Settings in Desktop.DDD (default file).

 

When opening DIAdem again you should see your new template in SCRIPT. Do not forget to save the template with another name before editing it, otherwise it will be changed when opening DIAdem again.

 

Feel free to ask if it is not clear or if it doesn't work 🙂

 

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 2 of 3
(2,874 Views)

Hello Michael,

 

With the help of some people who are smarter than me, I was able to put together this little Script that you can use to replace the "New" Script button in the Script panel. It renames the "New" button and you can add anything you want to this function:

 

NewActionObjName = "SCRAutEdFileNewCustom"
Set Bar = BarManager.Bars("SCRMain")
IF BarManager.ActionObjs.Exists(NewActionObjName) THEN
  Call BarManager.ActionObjs.Remove(NewActionObjName) 
END IF
Set NewActionObj = BarManager.ActionObjs.Add(NewActionObjName, "CustomButton") 
Set OldActionObj = BarManager.ActionObjs("SCRAutEdFileNew")
NewActionObj.Picture.FileName = OldActionObj.Picture.FileName
NewActionObj.Tooltip = "Add Custom VBScript"
NewActionObj.OnClickCode.Code = "MsgBox ""Hello New VBScript"""
Call Bar.UsedActionObjs.Add(NewActionObj)
n = Bar.UsedActionObjs.Count
Call Bar.UsedActionObjs.Move(n, 1)
Call Bar.UsedActionObjs.Remove(OldActionObj.ID)

I hope this is helpful, it was a little more involved than I had originally anticipated.

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 3 of 3
(2,854 Views)