Contact: zegraph  @  yahoo.com      Last update: January 2020

ZeScript Usage

You execute a ZeScript module by a command in a console window, e.g.,

C:\zs>zs.exe modulename

That, of course, assumes ZeScript being installed in the C:\zs directory in the Windows OS. The module name is the name of a script file (the extension may be omitted) and a script file name must have ".zs" extension. In the above example, there must be a script file named "modulename.zs" in C:\zs, C:\zs\cls, or C:\zs\lib, or C:\zs\cgi. To execute a module in any other directories, the full path to the module is required, e.g.,

C:\zs>zs.exe d:\myscript\mymodule

If no module name is given, ZeScript tries to execute a module having the same name as the executable, but the "zs" extension. Thus, by copying "zs.exe" to a different name, say "my.exe", and creating a module with the same name, i.e., "my.zs", you can make "my.exe" appears to br a self-executing programs to end-users, who may just double-click "my.exe" to execute "my.zs".

When you execute a module by a command line with options, e.g.,

C:\zs>zs.exe module opt1 name=John age=45 opt2

The program name, the module name, and the options can be accessed by the primitive function getarg(key). That is

getarg(0); //returns zs.exe as string
getarg(1); //returns module as string
getarg(2); //returns opt1 as string
getarg(3); //returns name=john as string
getarg(4); //returns age=45 as string
getarg(5); //returns opt2 as string

When an option contains the "=" character, the parts before and after "=" are also saved as a key-value pair and the value can be accessed through the key, e.g.,

getarg("name"); // returns John as string

Note that if the "=" is intended to pass key-value pairs to a script program, no space should be used before or after "=" because the operation system delimits options by space. However you may use the double quote to include spaces in a key or a value:

C:\zs>zs.exe module opt1 "my name=John Kerry" age=45 opt2