Guest User

Untitled

a guest
Sep 10th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.41 KB | None | 0 0
  1. proc progfile {file action arg} {
  2.     set arg [gbfilter $arg]
  3.          set return 0
  4.          set dbr [open database/$file.db r+]
  5.          set dbw [open tmp.tmp w+]
  6.     while {![eof $dbr]} {
  7.          set r [gets $dbr]
  8.     if {$r!=""} {puts $dbw $r}
  9.     }
  10.     close $dbr
  11.     close $dbw
  12.          set dbr [open tmp.tmp r+]
  13.          set dbw [open database/$file.db w+]
  14.     while {![eof $dbr]} {
  15.          set r [gets $dbr]
  16.     if {$action=="add"} {
  17.     if {$r!=""} {
  18.     puts $dbw $r
  19.     } else {
  20.     puts $dbw $arg
  21.     }
  22.          set return 1
  23.     }
  24.     if {$action=="del"} {
  25.     if {$r!=""} {
  26.     if {![string match -nocase $arg [lindex $r 0]] && ![string match -nocase $arg [lindex $r 1]]} {
  27.     puts $dbw $r
  28.     } else {
  29.          set return 1
  30.             }
  31.         }
  32.     }
  33.     if {$action=="chk"} {
  34.     if {$r!=""} {
  35.     puts $dbw $r
  36.     if [string match -nocase [lindex $arg 0] [lindex $r 1]] {
  37.          set return [lindex $r 0]
  38.     if ![string match -nocase [lindex $arg 1] [lindex $r 2]] {set return 2}
  39.     if ![string match [lindex $arg 2] [lindex $r 3]] {set return 3}
  40.             }
  41.         }
  42.     }
  43.     if {$action=="icr"} {
  44.     if {$r!=""} {
  45.     puts $dbw $r
  46.     if [string match -nocase $arg [lindex $r 0]] {
  47.          set return 1
  48.             }
  49.         }
  50.     }
  51.     if {$action=="cf"} {
  52.     if {$r!=""} {
  53.     puts $dbw $r
  54.     if [string match -nocase [lindex $r 0] $arg] {
  55.          set return 1
  56.             }
  57.         }
  58.     }
  59.     if {$action=="ibr"} {
  60.     if {$r!=""} {
  61.     puts $dbw $r
  62.     if [string match -nocase $arg [lindex $r 1]] {
  63.          set return 1
  64.                 }
  65.             }
  66.         }
  67.  
  68.     }
  69.     close $dbr
  70.     close $dbw
  71.     return $return
  72. }
Add Comment
Please, Sign In to add comment