nscl_logo_small.gif (2463 bytes)

Pseudo command

HH00706_.jpg (6530 bytes)

Syntax

pseudo name parameters body
pseudo -list [pattern]
pseudo -delete name1 [name2... ]

Synopsis

The pseudo command allows you to create, list and delete dynamically computed pseudo parameters.

Detailed Description

Using the pseudo command you can

Pseudo parameters are parameters which are computed online as a function of existing parameters in the event (pseudo or raw).  See also:

Top

pseudo name parameters body

Defines the computation which produces the value of a pseudo parameter.  Pseudo parameter definition is a two step process. First a SpecTcl parameter is defined using the parameter command.  Next the pseudo command is used to define how that parameter is produced.

The name argument is the name of the parameter which will be computed.  It should be the same as the name of the parameter created in the parameter command.  The parameters is a Tcl formatted list of existing SpecTcl parameters on which the computation depends.  These parameters can be raw parameters or pseudo parameters for which the pseudo script has already been defined. Body is a Tcl script body which computes the pseudo.  The script body will be converted into a procedure body with the independent parameters and their validity flags as its parameter list. The independent formal parameters will be named the same as the corresponding event parameter name. The validity flag associated with a parameter name will just have isValid appended to its name (e.g. nameisValid

example:  Summing two parameters:

Suppose the parameters par1 and par2 exist with resolution 10 bits.  The following sequence will define a pseudo called sum which will compute the sum of these two parameters:

parameter sum 1234 11     ;# Sum is Id 1234 11bits
pseudo sum { par1 par2 } {
   if {$par1isValid && $par2isValid} {
      return [expr $par1 + $par2]
   } else {
       return -1
   }
}
 

Top

How pseudo parameters work

An understanding of how pseudo parameters are implemented may be useful for pseudo writers.   The pseudo definition is converted into a procedure as follows:

proc name_Procedure parameters body

For each event, a call to this procedure is built with the appropriate parameters provided from the event.  The return value of the procedure is placed in the parameter corresponding to the pseudo.  The procedure is saved as compiled byte code so that it can be efficiently called again and again.

Top

pseudo -list [pattern ]

Lists pseudo parameters and their definitions.  Note that if a pattern is supplied only pseudo parameters whose name matches that pattern are litsed.  If a pattern is not provided, all pseudo parameters are listed.  Each parameter is described by a Tcl list.  The list contains:

In the example above the sum parameter will be listed as follows:

{sum {par1 par2} { return [expr $par1 + $par2] }}

Top

pseudo -delete name1 [name2... ]

Deletes one or more pseudo definitions.  Note that the parameter definition is not deleted.  Only the script which produces it. Several pseudo scripts can be deleted in a single command.

Top


Last Modified: October 28, 2003 by: fox@nscl.msu.edu
© Copyright NSCL 1999, All rights reserved