Sujet : Re: How to close a file if successfully opened De : mark (at) *nospam* qtrac.eu (Mark Summerfield) Groupes :comp.lang.tcl Date : 20. Jun 2024, 13:20:20 Autres entêtes Message-ID :<blSdnYwvfd4Zg-n7nZ2dnZfqn_ednZ2d@brightview.co.uk> References :1 User-Agent : Pan/0.154 (Izium; 517acf4)
I found a solution:
catch { try { set fh [::ini::open $::config::filename -encoding utf-8 r] set ::config::geometry \ [::ini::value $fh Window geometry [wm geometry .]] tk scaling [::ini::value $fh Window scale [tk scaling]] ttk::style theme use \ [::ini::value $fh Window theme [ttk::style theme use]] set ::config::tab [::ini::value $fh Window tab] } finally { if {[info exists fh] && $fh ne ""} { ::ini::close $fh } } } ;# ignore if file not found