Page 1 of 1

Clarification Running a script two ways.

Posted: Mon Jul 02, 2007 2:59 pm
by Ed Grossheim
7/2/2007 9:44:32 AM

Just asking for verification.

If I have a Vbs script meant to run via WScript Host, loaded in Zeus,
as the current document, and I execute a tool set as a Dos command with the argument:

"$fn"

then Zeus is executing my script via WScript Host --- Correct?

--------------------------------------------------------------------------------

Then if instead I (record a macro) to Macro\Execute Document as Script,
(looking at the Macro source I see the line:

call zeus.MacroExecuteDocument


This will execute the current document (though a vbs file) as a Zeus Macro, which must run the vbs file with an internal engine and not with WScript host. ---- Correct?

-----------------------------------------------------------

I want to be able to run my current document via WScript Host, so I use the Tool I made that uses the "$fn" argument.

I put this tool on my pop-up menu.

Apparently you cannot bind a Tool to a Key, only a Macro ? -----Correct?

If this is true, is there a way I can run my current document in WScript Host from a macro, that I could bind to a key?

---- Thanks, Ed

Posted: Tue Jul 03, 2007 12:03 am
by jussij
Hi Ed,
If I have a Vbs script meant to run via WScript Host, loaded in Zeus,
as the current document, and I execute a tool set as a Dos command with the argument:

"$fn"

then Zeus is executing my script via WScript Host --- Correct?
That is correct.

This is identical to using the Zeus Tools, Dos Shell menu and typing in the file name at the resulting DOS command line.

It is also the identical to using the Zeus Tools, Dos Command menu and typing in "$fn".
Then if instead I (record a macro) to Macro\Execute Document as Script,
(looking at the Macro source I see the line:

call zeus.MacroExecuteDocument

This will execute the current document (though a vbs file) as a Zeus Macro, which must run the vbs file with an internal engine and not with WScript host. ---- Correct?

This is pretty much correct ;)

To be precise the macro is definitely running inside the Zeus scripting engine, and can only be run from within the scripting engine, but it turns out the scripting engine actually uses WScript to run the script ;)

What you also need to remember is Zeus does not publish a Zeus scripting object to the outside WScript world. The Zeus scripting object is only available to the internal WScript used by the Zeus scripting engine.
Apparently you cannot bind a Tool to a Key, only a Macro ? -----Correct?

Not directly but indirectly yes.

The MacroExecuteXX, Tools ExecuteXX where XX is a number 1 through 20 are keyboard functions that run the first 20 items from the Macros and Tools menu.

So you can indirectly write a script to run a Macro or Tool but rememeber to add the Macro or Tool to the default document type.

For example this macro will run the first Item in the Macros menu:

Code: Select all

Sub key_macro()
    call zeus.MacroExecute01
End Sub

key_macro() 'run the macro
If this is true, is there a way I can run my current document in WScript Host from a macro, that I could bind to a key?

Alternatively the following VbScript macro will do the same thing:

Code: Select all

Sub key_macro()
    ' this macro only works for documents
    is_document = zeus.is_document()

    If is_document = 1 Then
        ' Option 1  = save current document
        ' Option 16 = use cmd.exe to run the command
        call zeus.system(zeus.macro_tag("$fn"), 1+16)

    Else
      ' give some feedback to the user
      line_of_text = "For this script to work you need to document window."
    End If

End Sub

key_macro() 'run the macro
You can then bind this macro to a keyboard key combination ;)

Cheers Jussi