Native Inspect Manual (H06.07+)
Using Tcl Scripting
Native Inspect Manual—528122-006
5-5
Tcl Examples
Tcl Examples
The code for the Native Inspect eq command is implemented in Tcl:
To create and use a simple Tcl command (allbases):
# Syntax: eq <expr>
#
# Effect: Evaluate the expression and display the result in different
# formats.
#
#------------------------------------------------------------------
proc eq { 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"
}
proc empty_str {str} {
expr { [scan $str "%s" tmp] == -1 }
#------------------------------------------------------------------
}
proc crunch_number {s endnum} {
return [string match {[-0-9#%]} [string index $s 0]]
}
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):










