Writing Zeus Macros Using Digital Mars Scripting

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Writing Zeus Macros Using Digital Mars Scripting

Post by jussij »

Since the Digital Mars Scripting implements the Windows Scripting Host interface, this means it is also possible to write Zeus macros using the DMD Scripting language.

To setup Zeus for DMDScript scripting do the following:
  1. Make sure you are running the latest version of Zeus
  2. Download the DMDScript component
  3. Using an admin command line prompt, register the DMDScript WSH using this command:

    Code: Select all

    regsvr32 dscript.dll
  4. Go to the Zeus install directory and create or edit the scriptwsh.ini file found here:

    Code: Select all

    C:\Users\<User ID>\AppData\Local\Programs\Zeus\scriptwsh.ini
    Th contents of that file needs to be replaced with the following changes:

    Code: Select all

    [Options]
    Language=DMDScript
    Extension=ds
    MacroBegin=function key_macro()\n{
    MacroEnd=}\n\nkey_macro()   // run the macro
    FunctionPrint=\tzeus.write("%s")
    FunctionPrefix=zeus.
    FunctionPostfix=;
    Enter=\n
    CRLF=\\n
    LineFeed=\r
    Tick='
    Quote=""
  5. Close and restart Zeus
  6. These INI file changes modify the behaviour of the scriptwsh.dll scripting module. To check these changes have been applied use the Options, Editor Options menu, select the Scripting panel and selected the scriptwsh.dll module, which should indicate the settings have been loaded as shown below:
    wsh.png
    wsh.png (73.56999999999999 KiB) Viewed 332 times
  7. Save this test macro to the zScript\test.ds file location.

    Code: Select all

    function key_macro()
    {
        zeus.screen_update_disable();
        zeus.FileNew();
        zeus.write("ScriptEngine: " + ScriptEngine() + "\n" +
                   "Build: " + ScriptEngineBuildVersion() + "\n\n");
        zeus.write("This is a Digital Mars macro script........\n")
        zeus.screen_update_enable();
        zeus.screen_update();
    }
    
    key_macro()   // run the macro
  8. To run the test macro use Macros, Execute Script menu and type in test.ds
The result of running the macro will create a new file and the contents of that file will be as shown below:
sf.png
sf.png (9.01 KiB) Viewed 331 times
Cheers Jussi
Post Reply