next up previous contents index
Next: Technology File Up: Main Functions 1 Previous: Prompt Line   Contents   Index

Scripts

(stringlist_handle) ListFunctions()
This function will re-read all of the library files in the script search path, and return a handle to a string list of the functions available from the libraries.

(untyped) Exec(script)
This function will execute a script. The argument is a string giving the script name or path. If the script is a file, it must have a ``.scr'' extension. The ``.scr'' extension is optional in the argument. If no path is given, the script will be opened from the search path or from the internal list of scripts read from the technology file or added with the !script command. If a path is given, that file will be executed, if found. It is also possible to reference a script which appears in a sub-menu of the User Menu by giving a modified path of the form ``@@/libname/.../scriptname''. The libname is the name of the script menu, the ... indicates more script menus if the menu is more than one deep, and the last component is the name of the script.

The return value is the result of the expression following ``return'' if a return statement caused termination of the script being executed. If the script did not terminate with a return statement with a following expression, the integer 1 is returned by Exec. If the script indicated by the argument to Exec could not be found, integer 0 is returned. If the return statement is used, the type of the return is determined by the type of object being returned.

Example: script1.scr

(executable lines)
return 3
in main script:
Print(Exec("script1")) # prints "3"

(int) SetKey(password)
This function sets the key used by Xic to decrypt encrypted scripts. The password must be the same as that used to encrypt the scripts. This function returns 1 on success, i.e., the key has been set, or 0 on failure, which shouldn't happen as even an empty string is a valid password.

(int) HasPython()
This function returns 1 if the Python language support plug-in has been successfully loaded, 0 otherwise.

(int) RunPython(command [, arg, ...])
Pass a command string to the Python interpreter for evaluation. The first argument is a path to a Python script file. Arguments that follow are concatenated and passed to the script. Presently, only string and scalar type arguments are accepted. The interpreter will have available the entire Xic scripting interface, though only the basic data types are useful. The Python interface description provides information about the header lines needed to instantiate the interface to Xic from Python (see 2.13).

This function exists only if the Python language support plug-in has been successfully loaded. The function returns 1 on success, 0 otherwise with an error message available from GetError.

(int) RunPythonModuleFunc(module, function [, arg ...])
This function will call the Python interpreter, to execute the module function specified in the arguments. The first argument is the name of the module, which must be known to Python. The second argument is the name of the function within the module to evaluate. Following are zero or more function arguments, as required by the function.

This function exists only if the Python language support plug-in has been successfully loaded. The function returns 1 on success, 0 otherwise with an error message available from GetError.

(int) ResetPython()
Reset the Python interpreter. It is not clear that a user would ever need to call this.

This function exists only if the Python language support plug-in has been successfully loaded. The function always returns 1.

(int) HasTcl()
This function returns 1 if the Tcl language support plug-in was successfully loaded, 0 otherwise.

(int) HasTk()
This function returns 1 if the Tcl with Tk language support plug-in was successfully loaded, 0 otherwise.

(int) RunTcl(command [, arg ...])
Pass a command string to the Tcl interpreter for evaluation. The first argument is a path to a Tck/Tk script. If both Tcl and Tk are available, the script file must have a .tcl or .tk extension. If only Tcl is available, there is no extension requirement, but the file should contain only Tcl commands. A Tcl script ie executed linearly and returns. A Tk script blocks, handling events until the last window is destroyed, at which time it returns.

Arguments that follow are concatenated and passed to the script. Presently, only string and scalar type arguments are accepted. The interpreter will have available the entire Xic scripting interface, though only the basic data types are useful. The Tcl/Tk interface description provides more information.

This function exists only if the Tcl language support plug-in has been successfully loaded. The function returns 1 on success, 0 otherwise with an error message available from GetError.

(int) ResetTcl()
Reset the Tcl/Tk interpreter. It is not clear that a user would ever need to call this.

This function exists only if the Tcl language support plug-in has been successfully loaded. The function always returns 1.

(int) HasGlobalVariable(globvar)
Return true if the passed string is the name of a global variable currently in scope. This is part of the exported global variable interface to Python and Tcl.

(int) GetGlobalVariable(globvar)
Return the value of the global variable whose name is passed. The function will generate a fatal error, halting the script, if the variable is not found, so one may need to check existence with HasGlobalVariable. The return type is the type of the variable, which can be any known type. This is for use in Python or Tcl scripts, providing access to the global variables maintained in the Xic script interpreter.

(int) SetGlobalVariable(globvar, value)
Set the value of the global variable named in the first argument. The function will generate a fatal error if the variable is not found, or the assignment fails due to type mismatch. This is for use in Python or Tcl scripts, providing access to the global variables maintained in the Xic script interpreter. Note that global variables can not be created from Python or Tcl, but values can be set with this function. Global variables can be used to return data to a top-level native script from a Tcl or Python sub-script.


next up previous contents index
Next: Technology File Up: Main Functions 1 Previous: Prompt Line   Contents   Index
Stephen R. Whiteley 2017-10-02