
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 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, but a different extension, as the program. 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 "zs.exe" appears as different self-executing programs to end-users, who may just 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 space in key or value:
C:\zs>zs.exe module opt1 "my name=John Kerry" age=45 opt2
The program ntservice.exe included in the ZeScript package is for runing ZeScript as a Windows NT (NT4.0, WIN2000, WIN2003, XP, VISTA, WIN7) service. Here are the procedures:
....
while(1) {
// do something here
sleep(1000)
}
....
sc.exe create ServiceName binPath= "path_to_ntservice.exe ServiceName zs.exe script.zs arg1 arg2 ...."
When the service is activated, it will create a process to execute the command "zs.exe scrupt.zs arg1 arg2 ..."
sc.exe start ServiceName
And if necessary, change the service type from manual start to auto start from the control panel.