Code: Select all
set thestb [lindex $text 1]
set in [open "triggers.txt" r]
set data [read $in]
set line [split $data \n]
set here [lsearch [string tolower $line] "$thestb *"]
Code: Select all
proc test:del {file num} {
set out [open $file r]
set data [read $out]
set line [split $data \n]
close $out
set out [open $file w]
set x 0
while {[lindex $line $x] != ""} {
if {$x != $num} {puts $out "[lindex $line $x]\r"}
incr x
}
close $out
}
Code: Select all
proc test:del {file num criteria} { ;# criteria is must ot be "word2"
set out [open $file r]
set data [read $out]
set line [split $data \n]
close $out
set out1 [open $file w] ;# $out i use diferent names to w nad r
foreach delline $line {
if {[lindex $delline 0] == "$criteria" && [lindex $delline 0] != ""} {
putlog "$delline" ;# if you see this is efcet in log !!!!! 1 !!!!!!
puts $out1 "$delline"
}
}
close $out1
}
actually beif {[lindex $delline 0] == "$criteria" && [lindex $delline 0] != ""} {
putlog "$delline" ;# if you see this is efcet in log !!!!! 1 !!!!!!
puts $out1 "$delline"
}
in order to put the non deleted info into the file?if {[lindex $delline 0] != "$criteria" && [lindex $delline 0] != ""} {
putlog "$delline" ;# if you see this is efcet in log !!!!! 1 !!!!!!
puts $out1 "$delline"
}
Code: Select all
proc StartFilter {File Pattern} {
if {[info exists ::FilterLockfile] && $::FilterLockfile == 1} {return 0}
set ::FilterLockfile 1
set fIdRead [open "$File" "RDONLY"]
while {[file exists [set tmpfile [file join ${temp-path} [randstring 8]]]]} {}
set fIdWrite [open "$tmpfile" "WRONLY CREAT"]
fconfigure $fIdRead -blocking 0
ProcessFile $fIdRead $fIdWrite $Pattern [list file rename -force -- $tmpfile $File]
}
proc ProcessFile {ReadFId WriteFId Pattern Cleanup} {
if {[gets $ReadFId string] == -1 && [eof $ReadFId]} {
close $ReadFId
close $WriteFId
eval $Cleanup
set ::FilterLockfile 0
} {
if {![string equal -nocase $Pattern [lindex [split $string] 0]]} {
puts $WriteFId $string
}
utimer 1 [list ProcessFile $ReadFId $WriteFId $Pattern $Cleanup]
}
}