jeudi 11 juin 2020

if statement TCL

proc test {} {

set infile [open "infile" r]
set linecount 0

while {[gets $infile line] > 0 {
    incr linecount

    set price [split $line ","]


    if {[reqexp  "Game" $price]} {

       set token [lindex $price end-3]
       set token1 [lindex $price end-2]

    } else {
       if {2 < $linecount < 4} {
       set token [lindex $price end-3]
       set token1 [lindex $price end-2]

       puts "$game"

}
}
}
close $infile

}

I have input file with many lines: I want to be able to puts line 2 to 4 but the if statement I put (if { 0 < $linecount < 2} , does not seem to be working . Do you know how I can ask the script to output for certain lines?

Game a b c
1 2 3 4
3 4 5 6
4 5 6 7
3 4 5 6      

Aucun commentaire:

Enregistrer un commentaire