#!/usr/bin/tclsh #----- little script which converts ukas Tanners error code header file into a #------ subroutine which converts into text set f [open MessagesCodes.h r] puts stdout "void slsdspCodeToText(int code, char *text, int textlen){" puts stdout " switch(code){" proc tokenize {txt} { set l [split $txt] foreach w $l { if {[string length $w] > 1} { lappend result $w } } return $result } while {[gets $f line] >= 0} { if {[string first "#define" $line] >= 0} { set l [tokenize $line] puts stdout " case [lindex $l 2]:" puts stdout " strncpy(text,\"[lindex $l 1]\",textlen);" puts stdout " break;" } } puts stdout " }" puts stdout "}" close $f exit 0