Regarding got to command in tcl -


i want print character next line:

say :

when variable dum=183 exists in file , print next charater next line.

note : using tcl

thanks,

this should started.

the typical idioms working file 1 line @ time are:

1) linewise reading:

set f [open thefile.txt] while {[gets $f line] >= 0} {     # work line of text in "line" } close $f 

2) block reading line splitting:

set f [open thefile.txt] set text [read $f] close $f set lines [split [string trim $text] \n] foreach line $lines {     # work line of text in "line" } 

this can simplified using package:

package require fileutil ::fileutil::foreachline line thefile.txt {     # work line of text in "line" } 

another way search , extract using regular expression. worst method inflexible , buggy in use.

set f [open thefile.txt] set text [read $f] close $f # regular expression example if {[regexp {\ydum\y[^\n]*.(.)} $text -> thecharacter]} {     # character wanted should in "thecharacter" } 

documentation: >= (operator), close, fileutil (package), foreach, gets, if, open, package, read, regexp, set, split, string, while, syntax of tcl regular expressions


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

Command prompt result in label. Python 2.7 -