Extral Convenience functions

Home    Binary distributions    Source distribution    Documentation

invoke vars cmd ...
invoke simply evals $cmd in a private space. This eg. allows using temporary variables in bindings without creating these in global scope. It is also very convenient to use values appended to a command given to a binding: Further arguments (when given) are parameters that will be available in the variables given in vars. If more parameters are supplied than vars are given, the remaining parameters will be stored in the variable args.
Extral::bgexec ?options? arg ?arg ...?
Without the -command option, this command works like exec does, but runs the executed processes in background. While the command will wait until the process is finished and returns the results, events will still be processed while the process is running; the bgexec does e.g. not block the interface from redisplaying when needed.
The command supports the folowing options
-command ?command?
With the -command option, bgerror does not wait for the process to finish. Instead, when the process is finished, the command in the option will be run (toplevel scope) with the result appended. In plain Tcl, the event loop must be running. More than one background jobs can be run at the same time using the -command option. The command supports the folowing options:
-timeout number
After the given number of miliseconds the process is stopped
-progresscommand command
This option is used to execute a command each time new data arrives. command is used as a prefix to run with the new data appended
name of a (global) variable to which the channel controlling the proces started wil be saved, can be used with Extral::bgexec_cancel to cancel running process
-pidvar varName
store the pid of the process in the variable varName
This option can turn of redirection of stderr; by default, if error output is present, bgexec will stop with an error, and the error output is in the result. Using this option, you can redirect error yourself, eg to stdout using \"2>@1\" on programs where stderr is used for progress reporting

 Extral::bgexec ./testcmd_bgexec.tcl
 Extral::bgexec -command {set v} ./testcmd_bgexec.tcl 2
 vwait ::v
list_iterate variableName list
debugging tool to interactively iterate a variable over a list. list_iterate is used to initialise and it sets the variable to the first element of the list. Every 'list_next variableName' will puts the next element into the variable.
list_next variableName
complement to list_iterate. sets the variable to the next element of the list first given by list_iterate.
aproc args body
aproc creates an 'anonymous' procedure; this means you don't have to provide a name. It returns the name to invoke it. These procedures are cached based on the arguments and body. This is actually somewhat similar to the invoke command, but is faster when the proc is being reused many times. Typical use would be in parameters that expect a command name that will be called later with a number of arguments: .ctable configure -getcommand [aproc {args} {return $args}]
? expr truevalue falsevalue
? expr truevalue falsevalue
echo string
echo returns its argument as a result This is useful when you want a command that will be evalled or upleveled to return a certain value
rem args
does nothing
I use this to put some example or testing code in a program without all the #'s
REM args
when the procedure remof is called, REM will also do nothing when the procedure remon is called, REM will put its arguments to the stdout
true expression
true expr returns 1 when expression is yes, true or 1
otherwise it returns 0.
setglobal varName ?newValue?
same as the set command, but then for global variables
random min max
returns a random number between min and max
putsvars varname ?varname ...?
returns the values of the given variables in the form:
set variable1 value1
set variable2 value2
preserves the error information in the variables errorInfo. Preserved information will be restored with the command error_restore
returns current time in astronomical format: "%Y-%m-%d %H:%M:%S"
Extral::event listen listener event command Extral::event remove listener event Extral::event generate event ?data? ... Extral::event events Extral::event listeners event Extral::event debug command
When an event is generated (using Extral::event generate) the commands previously defined and attched to the event by one or more listeners will invoked The command will be executed in global scope with the data (if any) given by the generate command appended
varsubst string varlist valuelist
substitutes only the variables in varlist for their content in the given string
	% set try {try it}
	try it
	% varsubst {try} {
		puts [list $try $try2]
		puts [list {try it} $try2]
get varName ?default?
get returns the value of the variable given by varName if it exists. If the variable does not exists, it returns an empty string, or value given by $default if present
Peter De Rijk
hosted at Get extral at SourceForge.net. Fast, secure and Free Open Source software downloads