The functions described in this section are common across all implementations of ScriptEase. They are included internally to the ScriptEase program. All of these routines are available to any program written in ScriptEase.
The following predefined values are used to know the version of ScriptEase that is running:
In version "2.10 GA" the following values would be defined
2 |
|
10 |
|
"GA" |
Depending on which version of ScriptEase is running, one (and only one) of the following values will be defined:
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
|
1 |
If ScriptEase is running as a shell, then the following will be defined:
1 |
If _WIN32_ is defined, then one of the following values will be defined as well:
1 |
|
1 |
|
1 |
|
1 |
Depending on whether the processor stores multi-byte Big-Endian or Little_Endian, BIG_ENDIAN will be defined in one of the following ways:
1 (i.e. TRUE) if processor stores high-byte first (e.g. Motorolla) |
|
0 (i.e. FALSE) if processor stores low-byte in low_memory (e.g. Intel) |
byte |
|
---|---|
DESCRIPTION |
Return numerical value as represented by a byte. |
SYNTAX |
byte byte(var v) |
RETURN |
Returns v as represented by a byte. |
SEE ALSO |
integer(), float() |
float |
|
---|---|
DESCRIPTION |
Return numerical value as represented by a floating-point number. |
SYNTAX |
float float(var v) |
RETURN |
Returns v as represented by a floating-point value. |
SEE ALSO |
byte(), float() |
integer |
|
---|---|
DESCRIPTION |
Return numerical value as represented by an integer. |
SYNTAX |
int integer(var v) |
RETURN |
Returns v as represented by an integer. |
SEE ALSO |
byte(), integer() |
ScreenClear |
|
---|---|
DESCRIPTION |
Clear screen. |
SYNTAX |
void ScreenClear() |
COMMENTS |
Clears the visible area of the screen. |
ShellFilterCharacter |
|
---|---|
DESCRIPTION |
Add character filter function to ScriptEase shell. |
SYNTAX |
void ShellFilterCharacter(string CharFltrFunction, bool AllKeys) |
COMMENTS |
When ScriptEase is running as a command shell (i.e., executed with no arguments), this allows you to install a function to be called when keystrokes are pressed. For example, the AUTOLOAD.CMM script that ships with ScriptEase uses this function to implement command-line history and file-name completion. AllKeys specifies whether the function will be called for every keystroke, or just for keys that are not ordinary printable (isprint()) characters. CharFltrFunction is the string name of a ScriptEase function of the type:
bool CharFltrFunction(string Command, int Position, int Key, Command is the current string on the shell's command line. This is read/write, so you may change the command string during this function call. Position is the current cursor position within the Command string. This may be altered during this function. Key is the key being pressed. This also may be altered. Set to 0 (zero) to ignore key input. Extended is TRUE if this is an extended keyboard character (e.g., function keys, key combinations, etc...) AlphaNumeric is TRUE if this is an alphabetic or numeric key (i.e., isalpha()). CharFltrFunction returns TRUE if the command line must be redrawn, or the cursor position moved, based on the actions in this function. |
RETURN |
None. |
ShellFilterCommand |
|
---|---|
DESCRIPTION |
Add command filter function to ScriptEase shell |
SYNTAX |
void ShellFilterCommand(string CmdFltrFunction) |
COMMENTS |
When ScriptEase is running as a command shell (i.e., executed with no arguments), this allows you to install a function to be called when commands have been entered. For example, the AUTOLOAD.CMM script that ships with ScriptEase uses this function to implement some commands, such as CD and TYPE. CmdFltrFunction is the string name of a ScriptEase function of the type: void CmdFltrFunction(string Command) Command is the current string on the shell's command line. This is read/write, so you may change the command string during this function call. The ScriptEase shell will execute this command after returning from this call. To prevent ScriptEase from executing any command (perhaps your filter handled the command internally) set Command to a zero-length string (e.g., Command[0]='\0', not Command=""). Before passing the command line to this filter function, ScriptEase will have stripped leading whitespace from the beginning and end of the command. Also, the redirection on a command line will not be seen by this function, because redirection is handled internally by ScriptEase. For example, if the command line string is "dir>dir.txt" then this function will only see the string "dir". |
RETURN |
None. |
spawn |
|
---|---|
DESCRIPTION |
Run an external executable. |
SYNTAX |
int spawn(int mode, string ExecutionCommandLine)
int spawn(int mode, string ExecutableSpec [, var arg1[, var arg2[, int spawn(int mode, string ExecutableSpec[, string[] ArgStrings]) |
COMMENTS |
This executes ExecutableSpec as a child process. This is more specific than the general standard library call "system()". ExecuteableSpec may be the name of a ScriptEase script, in which case the executable is understood to be the same version of ScriptEase as the one you're calling spawn from. ScriptEase scripts may be spawned as well as executables. Execute child program in one of these ways, depending on these pre-defined values of mode: P_WAIT Wait for the child program to complete before continuing. P_SWAP Like P_WAIT, but swap out ScriptEase to create more room for child process. P_NOWAIT Continue to run program while child program runs. P_OVERLAY This program exits and child program is executed in its place. In most C libraries this call requires an arg 0 to pass to the child, but in this library the ExecutableSpec is automatically passed as argument 0. Also, most libraries expect strings to be passed as the arguments, but ScriptEase will implicitly convert the arguments into strings before passing them on to the child process. You cannot spawn a script that has been bound with the ScriptEase /BIND function. |
|
DOS P_WAIT , P_SWAP , or P_OVERLAY Searches for ExecutableSpec in the current directory then in the directories of the PATH environment variable. If there is no extension on ExecutableSpec it will search first for .COM then .EXE files. P_SWAP will free up as much memory as possible by swapping ScriptEase to EMS/XMS/INT15 memory or to disk (in TMP directory, else TEMP, else current directory) before executing the child process (thanks to Ralf Brown for his excellent spawn library). If a batch file is being spawned, and if the environment variable COMSPEC_ENV_SIZE exists, then the command processor will be provided with this much memory for handling environment variables. If COMSPEC_ENV_SIZE does not exist then the command processor receives only enough memory for existing environment variables. |
|
DOS32 P_WAIT Searches for ExecutableSpec in the current directory then in the directories of the PATH environment variable. If no extension on ExecutableSpec then will search for .COM then .EXE files. If a batch file is being spawned, and if the environment variable COMSPEC_ENV_SIZE exists, then the command processor will be provided with this much memory for handling environment variables. If COMSPEC_ENV_SIZE does not exist then the command processor receives only enough memory for existing environment variables. |
|
OS/2 P_WAIT , P_NOWAIT Searches for ExecutableSpec in the current directory then in the directories of the PATH environment variable. If no extension on ExecutableSpec then will search for .COM then .EXE files. |
|
WINDOWS P_WAIT , P_NOWAIT Successful P_NOWAIT return id is the window handle of the child process. |
RETURN |
Returns -1 for error and sets errno to identify the error. For success returns the exit code of the child process for P_WAIT, does not return for P_OVERLAY, else returns the an identifier of the child process. |
SEE ALSO |
system() |
EXAMPLES |
This example calls a mortgage program MORTGAGE.EXE which takes three parameters, initial debt, rate, and monthly payment, and returns number of months needed to pay the debt in its exit code: months = spawn(P_WAIT,"MORTGAGE.EXE 300000 10.5 1000"); if (months < 0) printf("Error spawning MORTGAGE\n"); else printf("It takes %d months to pay off the mortgage\n", months); The parameters could also be passed to MORTGAGE.EXE as separate variables: months = spawn(P_WAIT,"MORTGAGE.EXE",300000,10.5,1000); The same arguments could be passed to MORTGAGE.EXE in a variable array, provided that they are all he same data type (in this case strings): MortgageData[0] = "300000"; MortgageData[1] = "10.5"; MortgageData[2] = "1000"; ths = spawn(P_WAIT,"MORTGAGE.EXE",MortageData); |
SplitFileName |
|
---|---|
DESCRIPTION |
Determine directory, name, and extension parts of a file specification. |
SYNTAX |
structure SplitFileName(string FileSpec) |
COMMENTS |
Splits the FileSpec into its various components that conform to the conventions of the operating system: dir, name, and ext, where: . dir name of the directory, including leading and drive separator characters . name root name of the file . ext extension name of the file, including preceding dot (.) All components are guaranteed to be non-NULL, and FileSpec can be reconstructed with this source statement: FileSpec = strcat(strcat(dir,name),ext) |
RETURN |
Returns a structure with the dir, name, and ext member variables set to non-NULL strings. |
SEE ALSO |
Directory(), FullPath() |
EXAMPLE |
The following two lines show results from sample inputs to SplitFileName() (the second example applies to the file structure for DOS and OS/2): // sets parts.dir="", parts.name="foo", parts.ext="" parts = SplitFileName("foo")
// parts.dir="..\\", parts.name="*", parts.ext=".doc" parts = SplitFileName("..\\*.doc") |
StructureMember |
|
---|---|
DESCRIPTION |
Access structure member by name. |
SYNTAX |
var StructureMember(structure StructureVariable, string MemberName) |
COMMENTS |
This function will act on a member of a structure by name. StructureVariable is a structure, and MemberName is the ascii string to represent the member. The variable returned by this function may be used as an lvar. |
RETURN |
Return variable for this structure member. May be used as a lvar. |
EXAMPLE |
The following example code: Point.row = 5; Point.col = 8; could be replaced by this sample code: StructureMember(Point,"row") = 5; StructureMember(Point,"col") = 8; |
Suspend |
|
---|---|
DESCRIPTION |
Suspend program execution for a specified amount of time. |
SYNTAX |
void Suspend(int milliSecondDelay) |
COMMENTS |
Your program may want to suspend itself for a limited time without abusing system resources, especially in multitasking systems. This function allows your program to use as little resources as possible for the length of this delay. Total millisecond accuracy is not guaranteed, but is only approximated according to the accuracy provided by the underlying operating system. |
EXAMPLE |
To suspend execution of your code for 1/2 second: Suspend(500); |
undefine |
|
---|---|
DESCRIPTION |
Make a variable undefined. |
SYNTAX |
void undefine(var v) |
COMMENTS |
Clear this variable data. Further calls to defined(v) will return false. If used on an element of an array, then this only has effect if the element of v is a structure, in which case it undefines all elements of the structure. |
RETURN |
None. |
MODIFIES |
v becomes undefined. |
SEE ALSO |
DataType(), DataDimension(), defined() |