Path: ...!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Fri, 21 Jun 2024 09:47:21 +0000 From: Mark Summerfield Subject: Re: How to close a file if successfully opened Newsgroups: comp.lang.tcl References: MIME-Version: 1.0 User-Agent: Pan/0.154 (Izium; 517acf4) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: Date: Fri, 21 Jun 2024 09:47:21 +0000 Lines: 23 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-RSwehpa11n06YhHyES/4nnmwqM1ftl3aZropKfGLjayhcZeljmuxyekJsZH7tFDa+6CGdJEKB3gNZ7b!2gzw39SfJ5PbqoV0v5LIEbGtK1bsDoJYFCnE5qKCkBvoZZx12SNLbsVUk6tb67b9nRvvCb+W443s!OzNgePTnw0eILQp6VkYKDAAaSA== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Bytes: 1833 I tried using both trap and finally but it didn't work. Having seen your code quotes I realise that I made a mistake with the syntax, so here's what I used in the end: 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] } trap {POSIX ENOENT} {} { ;# do nothing and rely on defaults } finally { if {[info exists fh] && $fh ne ""} { ::ini::close $fh } } I'd gone wrong in the trap; I'd forgotten the second set of braces. Thank you.