Native Inspect Manual (H06.03+)

Table Of Contents
Using Tcl Scripting
Native Inspect Manual528122-003
4-6
Tcl Examples
To create and use a simple Tcl command (allbases):
To use a Tcl command (ListPCBs) to walk data structure (symexpr is a Tcl
command used to evaluate symbolic expressions):
file: mytcl
#------------------------------------------------------------------
# Syntax: allbases <expr>
# Effect: Evaluate the expression and display the result in different
# formats.
#------------------------------------------------------------------
proc allbases { args } {
# sanity check
if { ! [llength args] } {
SYNTAX_ERROR eq
}
set result [matheval $args]
set char [ASCII $result]
PUT "\n"
PUT "OCT: [format %06o $result] DEC: [format %-5d $result] HEX:
0x[format
%04x $result] ASCII: \'$char\'\n"
}
(eInspect 3,615):tcl source mytcl
(eInspect 3,615):allbases 304
OCT: 000460 DEC: 304 HEX: 0x0130 ASCII: '...0'
(eInspect 3,615):
#------------------------------------------------------------------
# Syntax: ListPCBS
# Synopsis: Walk the PCBList, printing info about each PCB
#------------------------------------------------------------------
proc ListPCBs { } {
set pcbCount [FORMAT [SYMEXPR PCBList.count] short DEC]
PUT "\n$pcbCount Active PCBs\n"
PUT "pin\tflags\tattributes\n"
for { set i 0 } { [expr $i < $pcbCount] } { incr i } {
set pin [SYMEXPR PCBList.entry\[$i\]->ref.pcb->pin]
set flags [SYMEXPR PCBList.entry\[$i\]->ref.pcb->flags.word]
set attributeCount [SYMEXPR PCBList.entry\[$i\]->ref.pcb-
>attributeCount]
PUT "[FORMAT $pin short DEC]\t[FORMAT $flags short]\t[FORMAT
$attributeCount short DEC]\n"
}
}