I Am Very Happy ...
The latest script that I wrote was to modify field definitions (CHAR-SET/SCHEMA/FIELDS/FLD-ID/DTYPES/DATA) and add an additional column in the DATA field. The DATA field has to be modified on certain condition and he claimed that it was almost impossible to do it in Excel. Basically you need to change the content of the field from EARS<numbers> to INC0<numbers> and it has to be applied to the last occurrence of the field. It is not too difficult to do it in Tcl and below is the code snippet.
set field1 [lindex $line 0] switch $field1 { CHAR-SET - SCHEMA { puts $fpw $line } FIELDS { puts $fpw "$line \"Worklog Type\"" } FLD-ID { puts $fpw "$line 88888888" } DTYPES { puts $fpw "$line CHAR" } DATA { # change the last EARS to INC0 # append quoted string "8000" set p1 [string last EARS $line] if { $p1 >= 0 } { set line [format {%s%s%s} \ [string range $line 0 [expr {$p1-1}]] \ INC0 \ [string range $line [expr {$p1+4}] end] \ ] } puts $fpw "$line \"8000\"" } * { puts $fpw $line } } }
BTW, half of my code is meant for the GUI.
Another thing that made me happy is that I realised someone started to read my blog.
Labels: shell script, Tcl
0 Comments:
Post a Comment
<< Home