I'm working on a tcl script which should clear all lines older as 5 days from a file.
The lines ar timestamped in format: DD/MM/YY hh:mm:ss <line>
i got this now:
Code: Select all
foreach line [split $file "n"] {
if { $line != "n" || $line != " n" || $line != " " } {
set fdate [lindex [split $line " "] 0]
set fday [lindex [split $fdate "/"] 0]
set fmonth [lindex [split $fdate "/"] 1]
set fyear [lindex [split $fdate "/"] 2]
set day3 [checkdate $fday $fmonth $fyear $day $month $year]
putserv "PRIVMSG $chn :$day3 test"
if { $day3 == 1 } { putserv "PRIVMSG $chn : 1" }
if { $day3 != 1 } { puts $file1 $line }
}
}
It works with if's and switches (all with " before and after the values, the var's are strings).
This won't work (correctly).
I also created a proc toint, this converts a string to an int (it's a switch that returns 01 if string is "01", 02 if string is "02" and so on), and checked with simple if's (if { [toint $fday] < [expr [toint $day] +5] } { ...} and sort of xtra checks fore month and year), but it won't work.
Can someone help me plz??
I know it's kinda hard, but i dunno why it won't work.
Greejtz, Zygo.