'First command has no return value
'and is implemented as a vbscript "sub"
set cmd = Application.CreateCommand("NoReturnValue")
cmd.ScriptingName = "NoReturnValue"
cmd.Handler = "Foo"
cmd.Code = _
"sub Foo() " & vbCrLf & _
" Logmessage ""NoReturnValue called"" " & vbCrLf & _
"end sub"
cmd.Language = "VBScript"
cmd.ReturnValue = false
Application.AddCommand cmd
'The second command does return the value 56
'and is implemented as a vbscript "function"
set cmd = Application.CreateCommand("ReturnValue")
cmd.ScriptingName = "ReturnValue"
cmd.Handler = "Foo"
cmd.Code = _
"function Foo() " & vbCrLf & _
" Foo = 56" & vbCrLf & _
"end function"
cmd.Language = "VBScript"
cmd.ReturnValue = true
Application.AddCommand cmd
' Call our new commands
NoReturnValue
LogMessage( ReturnValue )
'Cleanup
Application.RemoveCommand( "NoReturnValue" )
Application.RemoveCommand( "ReturnValue" )
'The following results will be logged
'INFO : NoReturnValue called
'INFO : 56 |