Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Insufficient facts always invite danger. -- Spock, "Space Seed", stardate 3141.9


devel / comp.lang.tcl / Re: Optionally setting a default value once a value is entered?

SubjectAuthor
* Optionally setting a default value once a value is entered?snosniv
`* Optionally setting a default value once a value is entered?Rich
 `- Optionally setting a default value once a value is entered?snosniv

1
Optionally setting a default value once a value is entered?

<c4408160-4dd9-4734-a793-b8ed56dee57en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10063&group=comp.lang.tcl#10063

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:19cb:b0:4bb:6a28:83bc with SMTP id j11-20020a05621419cb00b004bb6a2883bcmr41303188qvc.102.1667745647982;
Sun, 06 Nov 2022 06:40:47 -0800 (PST)
X-Received: by 2002:a05:6214:b62:b0:4bb:9c0f:e923 with SMTP id
ey2-20020a0562140b6200b004bb9c0fe923mr40742604qvb.102.1667745647808; Sun, 06
Nov 2022 06:40:47 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sun, 6 Nov 2022 06:40:47 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=82.1.128.13; posting-account=gstOigoAAADV9pmzZL58qQ436SKV3SBu
NNTP-Posting-Host: 82.1.128.13
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c4408160-4dd9-4734-a793-b8ed56dee57en@googlegroups.com>
Subject: Optionally setting a default value once a value is entered?
From: nivpars...@gmail.com (snosniv)
Injection-Date: Sun, 06 Nov 2022 14:40:47 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1259
 by: snosniv - Sun, 6 Nov 2022 14:40 UTC

My script asks the user to enter a value which, if the user then ticks a checkbutton, this value is retained for the next time the script is opened.

I'm guessing I'd have to write back to the script, or is there a cleaner/simpler way?

TIA , Kev P.

Re: Optionally setting a default value once a value is entered?

<tk8m5f$36ebs$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10065&group=comp.lang.tcl#10065

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Optionally setting a default value once a value is entered?
Date: Sun, 6 Nov 2022 16:08:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <tk8m5f$36ebs$1@dont-email.me>
References: <c4408160-4dd9-4734-a793-b8ed56dee57en@googlegroups.com>
Injection-Date: Sun, 6 Nov 2022 16:08:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="072e88c7634f0de97804a9a40d84edf1";
logging-data="3357052"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lC5ut2tvpOjFfX3x1sCx4"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:AeEH51jdtb7gZKV9G0EQd43r9aA=
 by: Rich - Sun, 6 Nov 2022 16:08 UTC

snosniv <nivparsons@gmail.com> wrote:
> My script asks the user to enter a value which, if the user then
> ticks a checkbutton, this value is retained for the next time the
> script is opened.
>
> I'm guessing I'd have to write back to the script, or is there a
> cleaner/simpler way?

That is /one/ way -- but you will immediately be thrust headfirst into
'self-modifying code' territory that way, and for modern OS's that
offer file ownership protections, if the user running the script does
not have write access to the actual script file, the write-back will
fail.

And, for true multi-user setups, even if the writes were to succeed,
writing back to the script itself would mean that user X+1 receives the
default that user X set. And this is probably not what you want.

The more usual way is to store this 'value' into a config file, owned
and accessible exclusively by the user running the script, and upon
startup the script first checks for presence of the config file, and if
present, uses the value stored therein to 'pre-setup' the defaults.
And checking the box would create the config file (if it was not
already created at script startup anyway).

The 'ini' package in Tcllib can assist greatly with handling
(read/write/create) of the actual config file.

Then you just have to pick a storage place. On Linux that would
likely best be ~/.config/Your-Scripts-Name-Here/defaults.ini (assuming
you picked to use the 'ini' package, and named the file 'defaults').

Re: Optionally setting a default value once a value is entered?

<6515c7ea-fb63-4b28-a9c3-8d294ef14b7an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10067&group=comp.lang.tcl#10067

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:21e3:b0:4bb:dda8:ef28 with SMTP id p3-20020a05621421e300b004bbdda8ef28mr38745017qvj.42.1667763610002;
Sun, 06 Nov 2022 11:40:10 -0800 (PST)
X-Received: by 2002:a05:622a:1144:b0:3a5:24af:bc27 with SMTP id
f4-20020a05622a114400b003a524afbc27mr31307146qty.425.1667763609798; Sun, 06
Nov 2022 11:40:09 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sun, 6 Nov 2022 11:40:09 -0800 (PST)
In-Reply-To: <tk8m5f$36ebs$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=82.1.128.13; posting-account=gstOigoAAADV9pmzZL58qQ436SKV3SBu
NNTP-Posting-Host: 82.1.128.13
References: <c4408160-4dd9-4734-a793-b8ed56dee57en@googlegroups.com> <tk8m5f$36ebs$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6515c7ea-fb63-4b28-a9c3-8d294ef14b7an@googlegroups.com>
Subject: Re: Optionally setting a default value once a value is entered?
From: nivpars...@gmail.com (snosniv)
Injection-Date: Sun, 06 Nov 2022 19:40:09 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2946
 by: snosniv - Sun, 6 Nov 2022 19:40 UTC

On Sunday, 6 November 2022 at 16:08:18 UTC, Rich wrote:
> snosniv <nivpa...@gmail.com> wrote:
> > My script asks the user to enter a value which, if the user then
> > ticks a checkbutton, this value is retained for the next time the
> > script is opened.
> >
> > I'm guessing I'd have to write back to the script, or is there a
> > cleaner/simpler way?
> That is /one/ way -- but you will immediately be thrust headfirst into
> 'self-modifying code' territory that way, and for modern OS's that
> offer file ownership protections, if the user running the script does
> not have write access to the actual script file, the write-back will
> fail.
>
> And, for true multi-user setups, even if the writes were to succeed,
> writing back to the script itself would mean that user X+1 receives the
> default that user X set. And this is probably not what you want.
>
> The more usual way is to store this 'value' into a config file, owned
> and accessible exclusively by the user running the script, and upon
> startup the script first checks for presence of the config file, and if
> present, uses the value stored therein to 'pre-setup' the defaults.
> And checking the box would create the config file (if it was not
> already created at script startup anyway).
>
> The 'ini' package in Tcllib can assist greatly with handling
> (read/write/create) of the actual config file.
>
> Then you just have to pick a storage place. On Linux that would
> likely best be ~/.config/Your-Scripts-Name-Here/defaults.ini (assuming
> you picked to use the 'ini' package, and named the file 'defaults').

Ah yes, thanks for that.
I'm retired & this is my first return to Tcl/Tk after 5+ years of not touching it, brain dump worse than I thought. :-(

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor