Run Scripts
Tcl/Tk scripts can be run in several ways.
- From the File menu, using the option
- From the Standard toolbar, using the Run Tcl Script button
- From a button on the Utility menu
- From a command file using *evaltclscript()
- Starting HyperWorks Desktop using the -tcl <filename> option
- Starting HyperWorks Desktop Batch using hmbatch -tcl <filename>
source test.tcl
::hwt::Source test.tcl
source C:/My_scripts/test.tcl
source C:/My_scripts/test.tcl
source C:\My_scripts\test.tcl
source "C:/Documents and Settings/Paul/My Documents/test.tcl"
source {C:/Documents and Settings/Paul/My Documents/test.tcl}
*createbutton(5, "My Script",0,0,10,BLUE,"",EvalTclScript,
"C:/My_scripts/my_script.tcl")
*beginmacro("EvalTclScript")
*evaltclscript($1,0)
*endmacro()
*evaltclscript("C:/My_scripts/my_script.tcl",0)
A command file may also be run by invoking HyperWorks Desktop using the -tcl<filename> option. This option launches a HyperWorks Desktop session and executes the script specified by <filename>. If *quit appears in the script HyperWorks Desktop will exit, otherwise HyperWorks Desktop will remain open.
The final option is to invoke HyperWorks Desktop in batch mode using hmbatch -tcl<filename>. HyperWorks Desktop batch mode does not launch a graphical display so any commands in the script that require a display are ignored or will generate an error. Once the script is complete, HyperWorks Desktop will exit, regardless of the existence of *quit in the script.