| Deutsch English Français Italiano |
|
<RJ-dna0mWOe00ej7nZ2dnZfqnPUAAAAA@brightview.co.uk> View for Bookmarking (what is this?) Look up another Usenet article |
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 <mark@qtrac.eu>
Subject: Re: How to close a file if successfully opened
Newsgroups: comp.lang.tcl
References: <bNicnXPg6cMFnOn7nZ2dnZfqnPadnZ2d@brightview.co.uk>
<v525m1$2ob03$1@dont-email.me>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <RJ-dna0mWOe00ej7nZ2dnZfqnPUAAAAA@brightview.co.uk>
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.