Can someone please provide

Can someone please provide a simple example or template on how to create a new internal command in vbscript.

I have been trying for days now, bit I cannot seem to get my command to show up under the internal commands.

Here is the test script I have tried:

[code] Function OnInit(initData)
initData.name = "Test"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = true

    dim cmd 
    cmd = data.AddCommand()
    cmd.name = "Test"
    cmd.method = "Test"
    cmd.desc = data.desc
    cmd.label = "Test"

End Function

Function Test()
   dim objCmd : Set objCmd = DOpus.NewCommand
   objCmd.RunCommand("Play ""F:\My Office Data\sounds\test.wav"" QUIET")
   Set objCmd = Nothing
End Function[/code]

If you turn on the log you'll see your script produces an error:

[quote] Error at line 9, position 2
Object required: 'data' (0x800a01a8)[/quote]

You've got data.AddCommand() but the parameter name is initData. Same problem three lines down from that.

Please read this help page to learn how to create a script Add-in: Script Add-ins
Following the instructions you'll get something like this for your test script:

[code]option explicit

' Test
'
'
' This is a script for Directory Opus.
' See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
'
'
'
' Called by Directory Opus to initialize the script
Function OnInit(initData)
initData.name = "Test"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = false

Dim cmd

Set cmd = initData.AddCommand
cmd.name = "Test"
cmd.method = "OnTest"
cmd.desc = ""
cmd.label = "Test"
cmd.template = ""

End Function

' Implement the Test command
Function OnTest(scriptCmdData)
dim objCmd : Set objCmd = DOpus.NewCommand
objCmd.RunCommand("Play "F:\My Office Data\sounds\test.wav"" QUIET"" QUIET")
Set objCmd = Nothing
End Function[/code]

Thanks kundal :smiley:

[quote="jon"]If you turn on the log you'll see your script produces an error:
[/quote]
Just wondering. How do you do that on a fresh install nowadays? I remember having to look through all the
menus and whatnot without success, then creating items for it myself.

Considering how "important" scripting has become in DO lately it might be preferable if there were
easily accessible menuitems for cli scripting, scripting page, and the scripting log from the get go.

Help > Logs > Other Logs.

Or anything else which opens the Utility Panel, then switch which panel is being shown from the drop down at the top of it.

None of this stuff is particularly hidden in the UI or the manual, especially for the type of people technical enough to write scripts. None of it is that useful to people who only want to use scripts and not write them. So it seems OK as it is to me.

[quote="leo"]Help > Logs > Other Logs.

Or anything else which opens the Utility Panel, then switch which panel is being shown from the drop down at the top of it.[/quote]
Ah, there it was. It isn't exactly the most logical place to look for it.
Considering the lack of a View menu, I would've thought it logically belonged under tools.
My suggestion stands though.