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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -