file ordali_StrucObj.tcl
couldn't open "ordali_StrucObj.tcl": permission denied
    while executing
"open $f w"
    (procedure "Traite" line 6)
    invoked from within
"Traite $f"
    ("foreach" body line 3)
    invoked from within
"foreach f [lsort [glob ordali_*.tcl]] {
    puts "file $f"
    Traite $f
    puts ""
}"
    (in namespace eval "::request" script line 111)
    invoked from within
"namespace eval ::request $script"
    ("::try" body line 12)

OUTPUT BUFFER:

#!/home/moumou/tcl8.6b1/lubin/bin/tclsh8.6 proc LesLignesDuFichier f { set c [open $f r] set l [read -nonewline $c] close $c return [split $l \n] } proc Traite {f} { set foo [open $f r] set Ll [split [read -nonewline $foo] \n] close $foo set o [open $f w] set P 0 set Lv [list] set buf [list] foreach l $Ll { lappend buf $l set nl $l switch -regexp -- [string trim $nl] { {^proc } { if {! $P} { set P 1 } else { # traitement puts [lindex [split [lindex $buf 0] " "] 1] foreach m [lrange $buf 0 end-1] { set wout 1 if {[regexp {^global } [string trim $m]]} { foreach e [array names Pris] { if {$Pris($e)} {continue} if {$e in [split $m " "]} { puts "\tenleve $e" set i [lsearch [split $m " "] $e] set m [join [lreplace [split $m " "] $i $i] " "] } } if {[string trim $m] eq "global"} {set wout 0} } if {$wout} {puts $o $m} } # Remet a jour set Lv {} catch {unset Pris} set buf [list] lappend buf "$l" } } {^#} { continue } {^global} { regsub -all { +} [string trim $nl] " " nl set nl [split [string trim $nl] " "] set ip -1 set ix 1 foreach e [lrange $nl 1 end] { if {[regexp {^PDB_} $e]} { set ip [expr {$ix+1}] incr ix continue } if {$ip != $ix} { set Pris($e) 0 lappend Lv $e } incr ix } } default { regsub -all {\"|\$|\]|\:|\(|\.|\}|\{} $nl " " nl set lnl [split $nl " "] foreach v $Lv { #puts "[expr {$v in $lnl}] $v $nl" if {$v in $lnl} {set Pris($v) 1} } } } } # Derniere proc # traitement puts [lindex [split [lindex $buf 0] " "] 1] foreach m $buf { set wout 1 if {[regexp {^global } [string trim $m]]} { foreach e [array names Pris] { if {$Pris($e)} {continue} if {$e in [split $m " "]} { puts "\tenleve $e" set i [lsearch [split $m " "] $e] set m [join [lreplace [split $m " "] $i $i] " "] } } if {[string trim $m] eq "global"} {set wout 0} } if {$wout} {puts $o $m} } puts $o "" close $o return } foreach f [lsort [glob ordali_*.tcl]] { puts "file $f" Traite $f puts "" } exit