Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Simplicity does not precede complexity, but follows it.


devel / comp.lang.tcl / Re: File write problem.

SubjectAuthor
* File write problem.snosniv
`* File write problem.Arjen Markus
 +- File write problem.snosniv
 `* File write problem.snosniv
  `* File write problem.Ralf Fassel
   `* File write problem.snosniv
    `* File write problem.Rich
     `* File write problem.snosniv
      +- File write problem.snosniv
      +* File write problem.Rich
      |`- File write problem.snosniv
      `- File write problem.Helmut Giese

1
File write problem.

<39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:1a88:b0:3a4:ef5c:c69d with SMTP id s8-20020a05622a1a8800b003a4ef5cc69dmr569787qtc.194.1668160065851;
Fri, 11 Nov 2022 01:47:45 -0800 (PST)
X-Received: by 2002:a05:620a:141a:b0:6fa:f76d:bbc1 with SMTP id
d26-20020a05620a141a00b006faf76dbbc1mr425567qkj.11.1668160065680; Fri, 11 Nov
2022 01:47:45 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Fri, 11 Nov 2022 01:47:45 -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: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
Subject: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Fri, 11 Nov 2022 09:47:45 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1786
 by: snosniv - Fri, 11 Nov 2022 09:47 UTC

OK, I've built my "cycling" GUI and I get all the data I want into a nice list, something like this: {WARM 5 30 80 100} {BLCK 30 0 150 85} {COOL 5 100 80 80}
Where WARM mean warmup and the figures are:
mins secs start_power end_power (I could have another figure at end for cadence, but optional).
So, I can read those and write to my workout file, then the steady block, then the cool-down. (I can have other more complex stuff like intervals that ramp up in power etc).

Now, I double click on WISH and get a wish & associated tcl shell, I "source"
my top level file, and all works fine.
BUT, if I open my script by "open with" Wish Application, I get "permission denied" when I try to write my output file.

Is this something to do with Windows 10.
This is the last step that I need to get it all to work.

Re: File write problem.

<b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:5f54:0:b0:3a5:def:19fe with SMTP id y20-20020ac85f54000000b003a50def19femr641676qta.175.1668161245237;
Fri, 11 Nov 2022 02:07:25 -0800 (PST)
X-Received: by 2002:ac8:100d:0:b0:3a5:2751:ce81 with SMTP id
z13-20020ac8100d000000b003a52751ce81mr610529qti.322.1668161245095; Fri, 11
Nov 2022 02:07:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Fri, 11 Nov 2022 02:07:24 -0800 (PST)
In-Reply-To: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=62.194.189.128; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 62.194.189.128
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>
Subject: Re: File write problem.
From: arjen.ma...@gmail.com (Arjen Markus)
Injection-Date: Fri, 11 Nov 2022 10:07:25 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2216
 by: Arjen Markus - Fri, 11 Nov 2022 10:07 UTC

On Friday, November 11, 2022 at 10:47:47 AM UTC+1, snosniv wrote:
> OK, I've built my "cycling" GUI and I get all the data I want into a nice list, something like this: {WARM 5 30 80 100} {BLCK 30 0 150 85} {COOL 5 100 80 80}
> Where WARM mean warmup and the figures are:
> mins secs start_power end_power (I could have another figure at end for cadence, but optional).
> So, I can read those and write to my workout file, then the steady block, then the cool-down. (I can have other more complex stuff like intervals that ramp up in power etc).
>
> Now, I double click on WISH and get a wish & associated tcl shell, I "source"
> my top level file, and all works fine.
> BUT, if I open my script by "open with" Wish Application, I get "permission denied" when I try to write my output file.
>
> Is this something to do with Windows 10.
> This is the last step that I need to get it all to work.
I never use that option, but I can imagine that the program then starts in a directory that is indeed protected. Can you print it - puts [pwd] - in the console?

Regards,

Arjen

Re: File write problem.

<558d4a80-cfa3-4037-ae63-abbf9ce57aa5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:6690:0:b0:3a5:933:e8a9 with SMTP id d16-20020ac86690000000b003a50933e8a9mr635989qtp.676.1668162692890;
Fri, 11 Nov 2022 02:31:32 -0800 (PST)
X-Received: by 2002:ac8:44d7:0:b0:39c:c7ba:4af4 with SMTP id
b23-20020ac844d7000000b0039cc7ba4af4mr694797qto.99.1668162692715; Fri, 11 Nov
2022 02:31:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Fri, 11 Nov 2022 02:31:32 -0800 (PST)
In-Reply-To: <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.1.128.13; posting-account=gstOigoAAADV9pmzZL58qQ436SKV3SBu
NNTP-Posting-Host: 82.1.128.13
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com> <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <558d4a80-cfa3-4037-ae63-abbf9ce57aa5n@googlegroups.com>
Subject: Re: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Fri, 11 Nov 2022 10:31:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2571
 by: snosniv - Fri, 11 Nov 2022 10:31 UTC

On Friday, 11 November 2022 at 10:07:27 UTC, arjen.m...@gmail.com wrote:
> On Friday, November 11, 2022 at 10:47:47 AM UTC+1, snosniv wrote:
> > OK, I've built my "cycling" GUI and I get all the data I want into a nice list, something like this: {WARM 5 30 80 100} {BLCK 30 0 150 85} {COOL 5 100 80 80}
> > Where WARM mean warmup and the figures are:
> > mins secs start_power end_power (I could have another figure at end for cadence, but optional).
> > So, I can read those and write to my workout file, then the steady block, then the cool-down. (I can have other more complex stuff like intervals that ramp up in power etc).
> >
> > Now, I double click on WISH and get a wish & associated tcl shell, I "source"
> > my top level file, and all works fine.
> > BUT, if I open my script by "open with" Wish Application, I get "permission denied" when I try to write my output file.
> >
> > Is this something to do with Windows 10.
> > This is the last step that I need to get it all to work.

> I never use that option, but I can imagine that the program then starts in a directory that is indeed protected. Can you print it - puts [pwd] - in the console?
>
> Regards,
>
> Arjen

Yes, if I type puts [pwd] I get;
C:\ActiveTcl\User_files\MY_WORKOUT
which is the dir where my 4 tcl files are. (I "open" f00.tcl which sources the other 3 files, (f00 is not the real file name))

Re: File write problem.

<1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ae9:e814:0:b0:6ec:53ab:90ee with SMTP id a20-20020ae9e814000000b006ec53ab90eemr514659qkg.415.1668163164258;
Fri, 11 Nov 2022 02:39:24 -0800 (PST)
X-Received: by 2002:ac8:7c6:0:b0:3a5:460f:79c8 with SMTP id
m6-20020ac807c6000000b003a5460f79c8mr659622qth.501.1668163164086; Fri, 11 Nov
2022 02:39:24 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Fri, 11 Nov 2022 02:39:23 -0800 (PST)
In-Reply-To: <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.1.128.13; posting-account=gstOigoAAADV9pmzZL58qQ436SKV3SBu
NNTP-Posting-Host: 82.1.128.13
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com> <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>
Subject: Re: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Fri, 11 Nov 2022 10:39:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2907
 by: snosniv - Fri, 11 Nov 2022 10:39 UTC

On Friday, 11 November 2022 at 10:07:27 UTC, arjen.m...@gmail.com wrote:
> On Friday, November 11, 2022 at 10:47:47 AM UTC+1, snosniv wrote:
> > OK, I've built my "cycling" GUI and I get all the data I want into a nice list, something like this: {WARM 5 30 80 100} {BLCK 30 0 150 85} {COOL 5 100 80 80}
> > Where WARM mean warmup and the figures are:
> > mins secs start_power end_power (I could have another figure at end for cadence, but optional).
> > So, I can read those and write to my workout file, then the steady block, then the cool-down. (I can have other more complex stuff like intervals that ramp up in power etc).
> >
> > Now, I double click on WISH and get a wish & associated tcl shell, I "source"
> > my top level file, and all works fine.
> > BUT, if I open my script by "open with" Wish Application, I get "permission denied" when I try to write my output file.
> >
> > Is this something to do with Windows 10.
> > This is the last step that I need to get it all to work.
> I never use that option, but I can imagine that the program then starts in a directory that is indeed protected. Can you print it - puts [pwd] - in the console?
>
> Regards,
>
> Arjen

Yes, that works OK;

puts [pwd] ;# responds with:-

C:/ActiveTcl/User_files/MY_WORKOUT

I'm using this proc as a quick debug to try & get the write-file to work, "fname" comes from an entry widget, and I'll be writing data from a global list.
Probably not very elegant but the whole thing is moderately simple, but falling at last hurdle it seems.

proc build_workout {} {
global fname
set fout_name "CLUB_$fname.txt"
set fout [open $fout_name w]
puts $fout "dogs" ;# Try and write something!
close $fout
}

Re: File write problem.

<yga35ap4qk9.fsf@akutech.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: File write problem.
Date: Fri, 11 Nov 2022 13:35:18 +0100
Lines: 13
Message-ID: <yga35ap4qk9.fsf@akutech.de>
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
<b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com>
<1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net mFFMAvk9zuxoWhkGRhLj9Q4+MOUAWFZkR5VzA0GLpe84oLrdk=
Cancel-Lock: sha1:tder4ivkHXJL4pKRb8aJCQqCzpU= sha1:B8iLSTNv96FV9pe5iDmpwGKFVPw=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Fri, 11 Nov 2022 12:35 UTC

* snosniv <nivparsons@gmail.com>
| proc build_workout {} {
| global fname
| set fout_name "CLUB_$fname.txt"

Might be a good idea to include the full path of the file instead of
relying on where the app starts by coincidence:

set fout_name "c:/where/the/files/should/go/CLUB_$fname.txt"

Maybe make the directory part configurable.

R'

Re: File write problem.

<b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:1655:b0:6e0:90df:228f with SMTP id c21-20020a05620a165500b006e090df228fmr927845qko.756.1668172992788;
Fri, 11 Nov 2022 05:23:12 -0800 (PST)
X-Received: by 2002:ac8:1413:0:b0:3a5:591e:a605 with SMTP id
k19-20020ac81413000000b003a5591ea605mr1178714qtj.284.1668172992582; Fri, 11
Nov 2022 05:23:12 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Fri, 11 Nov 2022 05:23:12 -0800 (PST)
In-Reply-To: <yga35ap4qk9.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=82.1.128.13; posting-account=gstOigoAAADV9pmzZL58qQ436SKV3SBu
NNTP-Posting-Host: 82.1.128.13
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
<b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>
<yga35ap4qk9.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com>
Subject: Re: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Fri, 11 Nov 2022 13:23:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1909
 by: snosniv - Fri, 11 Nov 2022 13:23 UTC

On Friday, 11 November 2022 at 12:35:23 UTC, Ralf Fassel wrote:
> * snosniv <nivpa...@gmail.com>
> | proc build_workout {} {
> | global fname
> | set fout_name "CLUB_$fname.txt"
> Might be a good idea to include the full path of the file instead of
> relying on where the app starts by coincidence:
>
> set fout_name "c:/where/the/files/should/go/CLUB_$fname.txt"
>
> Maybe make the directory part configurable.
>
> R'
OK, thanks, will try that.
However, I've just found that if I "freewrap" myfiles into a single executable, it works, which was my final goal.
BUT, I will try your suggestion as I'd like to know why it worked or not depending on how invoked!

Re: File write problem.

<tkmhfi$v0ra$1@dont-email.me>

  copy mid

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

  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: File write problem.
Date: Fri, 11 Nov 2022 22:14:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <tkmhfi$v0ra$1@dont-email.me>
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com> <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com> <yga35ap4qk9.fsf@akutech.de> <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com>
Injection-Date: Fri, 11 Nov 2022 22:14:10 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="a6482baf5e5e83eb460ab84e29e6ca04";
logging-data="1016682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QnOB7dz2O0YXe3MmFPGRL"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:P0+Repgl0Q7sWCFPwEoQUkKSpgw=
 by: Rich - Fri, 11 Nov 2022 22:14 UTC

snosniv <nivparsons@gmail.com> wrote:
> On Friday, 11 November 2022 at 12:35:23 UTC, Ralf Fassel wrote:
>> * snosniv <nivpa...@gmail.com>
>> | proc build_workout {} {
>> | global fname
>> | set fout_name "CLUB_$fname.txt"
>> Might be a good idea to include the full path of the file instead of
>> relying on where the app starts by coincidence:
>>
>> set fout_name "c:/where/the/files/should/go/CLUB_$fname.txt"
>>
>> Maybe make the directory part configurable.
>>
>> R'
> OK, thanks, will try that.
> However, I've just found that if I "freewrap" myfiles into a single
> executable, it works, which was my final goal.
> BUT, I will try your suggestion as I'd like to know why it worked or
> not depending on how invoked!

If you were really trying to load files by relative name (your set
fout_name) above has no directory string, so it is a "relative" name)
then whether the "open" succeeds depends upon what "default directory"
is used to look for the files.

That "default directory" being the "current working directory" which
you can retreive using the "pwd" command (most likely short for (P)rint
(W)orking (D)irectory).

Upon startup, your script is assigned a current working directory by
the OS. MSWin seems to like to assign different current working
directories depending upon whether you launch from a cmd shell, a
shortcut, or let windows file extension lookup pick an executable.

The failures were likely due to MSWin giving you a current working
directory that was different from the directory where your scripts were
stored. So if your scripts were stored at c:\user\snosiv\script\ but
windows gave the process a current working directory of
c:\programs\tcl\bin then all your relative file accesses were looking
in c:\programs\tcl\bin for the filenames your script was trying to
open, and as they were not there, all the opens failed.

Re: File write problem.

<739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:1ccb:b0:3a5:311f:8004 with SMTP id bc11-20020a05622a1ccb00b003a5311f8004mr4517572qtb.627.1668239752120;
Fri, 11 Nov 2022 23:55:52 -0800 (PST)
X-Received: by 2002:a37:97c6:0:b0:6fa:4014:3b38 with SMTP id
z189-20020a3797c6000000b006fa40143b38mr4038291qkd.322.1668239751916; Fri, 11
Nov 2022 23:55:51 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Fri, 11 Nov 2022 23:55:51 -0800 (PST)
In-Reply-To: <tkmhfi$v0ra$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: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
<b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>
<yga35ap4qk9.fsf@akutech.de> <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com>
<tkmhfi$v0ra$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>
Subject: Re: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Sat, 12 Nov 2022 07:55:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4240
 by: snosniv - Sat, 12 Nov 2022 07:55 UTC

On Friday, 11 November 2022 at 22:14:13 UTC, Rich wrote:
> snosniv <nivpa...@gmail.com> wrote:
> > On Friday, 11 November 2022 at 12:35:23 UTC, Ralf Fassel wrote:
> >> * snosniv <nivpa...@gmail.com>
> >> | proc build_workout {} {
> >> | global fname
> >> | set fout_name "CLUB_$fname.txt"
> >> Might be a good idea to include the full path of the file instead of
> >> relying on where the app starts by coincidence:
> >>
> >> set fout_name "c:/where/the/files/should/go/CLUB_$fname.txt"
> >>
> >> Maybe make the directory part configurable.
> >>
> >> R'
> > OK, thanks, will try that.
> > However, I've just found that if I "freewrap" myfiles into a single
> > executable, it works, which was my final goal.
> > BUT, I will try your suggestion as I'd like to know why it worked or
> > not depending on how invoked!
> If you were really trying to load files by relative name (your set
> fout_name) above has no directory string, so it is a "relative" name)
> then whether the "open" succeeds depends upon what "default directory"
> is used to look for the files.
>
> That "default directory" being the "current working directory" which
> you can retreive using the "pwd" command (most likely short for (P)rint
> (W)orking (D)irectory).
>
> Upon startup, your script is assigned a current working directory by
> the OS. MSWin seems to like to assign different current working
> directories depending upon whether you launch from a cmd shell, a
> shortcut, or let windows file extension lookup pick an executable.
>
> The failures were likely due to MSWin giving you a current working
> directory that was different from the directory where your scripts were
> stored. So if your scripts were stored at c:\user\snosiv\script\ but
> windows gave the process a current working directory of
> c:\programs\tcl\bin then all your relative file accesses were looking
> in c:\programs\tcl\bin for the filenames your script was trying to
> open, and as they were not there, all the opens failed.

Thanks Rich, it's definitely something to do with the path.
After a bit of debugging this morning, I invoked my script from where it resides in C:\ActiveTcl\User_files\CYCLE
with the "Open with Wish application" after I added the following code:

set my_path [pwd]
set my_name "CLUB_$woname.zwo" ;# woname is set in an entry box, in this instance as "testwr"
set f_out [open $my_path/$my_name w]

And I get this message:

couldn't open "C:/Windows/System32/CLUB_testwr.zwo": permission denied.

So, I now see what's going on, thanks for the help in resolving that. :-)
BUT, I want to keep the script flexible such that whatever directory it's in,
file writes are to the same directory, I don't want to put a hard path to the directory.

I'm sure it's a simple fix, but can't seem to sort the wood from the trees.

Thanks, Kev P.

Re: File write problem.

<7a5f2664-91cb-44ca-b83a-aca86b2af0bcn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:7401:0:b0:3a5:41fd:2216 with SMTP id p1-20020ac87401000000b003a541fd2216mr4648916qtq.338.1668240450001;
Sat, 12 Nov 2022 00:07:30 -0800 (PST)
X-Received: by 2002:ac8:7303:0:b0:3a5:50fa:1a32 with SMTP id
x3-20020ac87303000000b003a550fa1a32mr4632347qto.11.1668240449759; Sat, 12 Nov
2022 00:07:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Sat, 12 Nov 2022 00:07:29 -0800 (PST)
In-Reply-To: <739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=82.1.128.13; posting-account=gstOigoAAADV9pmzZL58qQ436SKV3SBu
NNTP-Posting-Host: 82.1.128.13
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
<b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>
<yga35ap4qk9.fsf@akutech.de> <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com>
<tkmhfi$v0ra$1@dont-email.me> <739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7a5f2664-91cb-44ca-b83a-aca86b2af0bcn@googlegroups.com>
Subject: Re: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Sat, 12 Nov 2022 08:07:29 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4708
 by: snosniv - Sat, 12 Nov 2022 08:07 UTC

On Saturday, 12 November 2022 at 07:55:54 UTC, snosniv wrote:
> On Friday, 11 November 2022 at 22:14:13 UTC, Rich wrote:
> > snosniv <nivpa...@gmail.com> wrote:
> > > On Friday, 11 November 2022 at 12:35:23 UTC, Ralf Fassel wrote:
> > >> * snosniv <nivpa...@gmail.com>
> > >> | proc build_workout {} {
> > >> | global fname
> > >> | set fout_name "CLUB_$fname.txt"
> > >> Might be a good idea to include the full path of the file instead of
> > >> relying on where the app starts by coincidence:
> > >>
> > >> set fout_name "c:/where/the/files/should/go/CLUB_$fname.txt"
> > >>
> > >> Maybe make the directory part configurable.
> > >>
> > >> R'
> > > OK, thanks, will try that.
> > > However, I've just found that if I "freewrap" myfiles into a single
> > > executable, it works, which was my final goal.
> > > BUT, I will try your suggestion as I'd like to know why it worked or
> > > not depending on how invoked!
> > If you were really trying to load files by relative name (your set
> > fout_name) above has no directory string, so it is a "relative" name)
> > then whether the "open" succeeds depends upon what "default directory"
> > is used to look for the files.
> >
> > That "default directory" being the "current working directory" which
> > you can retreive using the "pwd" command (most likely short for (P)rint
> > (W)orking (D)irectory).
> >
> > Upon startup, your script is assigned a current working directory by
> > the OS. MSWin seems to like to assign different current working
> > directories depending upon whether you launch from a cmd shell, a
> > shortcut, or let windows file extension lookup pick an executable.
> >
> > The failures were likely due to MSWin giving you a current working
> > directory that was different from the directory where your scripts were
> > stored. So if your scripts were stored at c:\user\snosiv\script\ but
> > windows gave the process a current working directory of
> > c:\programs\tcl\bin then all your relative file accesses were looking
> > in c:\programs\tcl\bin for the filenames your script was trying to
> > open, and as they were not there, all the opens failed.
> Thanks Rich, it's definitely something to do with the path.
> After a bit of debugging this morning, I invoked my script from where it resides in C:\ActiveTcl\User_files\CYCLE
> with the "Open with Wish application" after I added the following code:
>
>
> set my_path [pwd]
> set my_name "CLUB_$woname.zwo" ;# woname is set in an entry box, in this instance as "testwr"
> set f_out [open $my_path/$my_name w]
>
> And I get this message:
>
> couldn't open "C:/Windows/System32/CLUB_testwr.zwo": permission denied.
>
> So, I now see what's going on, thanks for the help in resolving that. :-)
> BUT, I want to keep the script flexible such that whatever directory it's in,
> file writes are to the same directory, I don't want to put a hard path to the directory.
>
> I'm sure it's a simple fix, but can't seem to sort the wood from the trees.
>
> Thanks, Kev P.

I could use the command "tk_chooseDirectory", but that requires more user input (OK, not much),
but I'd much prefer to write to same dir as script resides, or possibly a sub-dir of script.

Kev P.

Re: File write problem.

<tko4u9$15s47$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: File write problem.
Date: Sat, 12 Nov 2022 12:52:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <tko4u9$15s47$1@dont-email.me>
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com> <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com> <yga35ap4qk9.fsf@akutech.de> <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com> <tkmhfi$v0ra$1@dont-email.me> <739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>
Injection-Date: Sat, 12 Nov 2022 12:52:26 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="0014cd6260b3b3119de9a596f087577d";
logging-data="1241223"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hroatfH62jjza8i7RoF0a"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:swXIiuDTvJaCUcvbf+9eS/a0OpQ=
 by: Rich - Sat, 12 Nov 2022 12:52 UTC

snosniv <nivparsons@gmail.com> wrote:
> On Friday, 11 November 2022 at 22:14:13 UTC, Rich wrote:
>> snosniv <nivpa...@gmail.com> wrote:
>> > BUT, I will try your suggestion as I'd like to know why it worked
>> > or not depending on how invoked!

>> If you were really trying to load files by relative name (your set
>> fout_name) above has no directory string, so it is a "relative"
>> name) then whether the "open" succeeds depends upon what "default
>> directory" is used to look for the files.
>>
>> That "default directory" being the "current working directory" which
>> you can retreive using the "pwd" command (most likely short for
>> (P)rint (W)orking (D)irectory).
>>
>> Upon startup, your script is assigned a current working directory by
>> the OS. MSWin seems to like to assign different current working
>> directories depending upon whether you launch from a cmd shell, a
>> shortcut, or let windows file extension lookup pick an executable.
>>
>> The failures were likely due to MSWin giving you a current working
>> directory that was different from the directory where your scripts
>> were stored. So if your scripts were stored at
>> c:\user\snosiv\script\ but windows gave the process a current
>> working directory of c:\programs\tcl\bin then all your relative file
>> accesses were looking in c:\programs\tcl\bin for the filenames your
>> script was trying to open, and as they were not there, all the opens
>> failed.
>
> Thanks Rich, it's definitely something to do with the path.
> After a bit of debugging this morning, I invoked my script from where
> it resides in C:\ActiveTcl\User_files\CYCLE with the "Open with Wish
> application" after I added the following code:
>
>
> set my_path [pwd]
> set my_name "CLUB_$woname.zwo" ;# woname is set in an entry box, in this instance as "testwr"
> set f_out [open $my_path/$my_name w]
>
> And I get this message:
>
> couldn't open "C:/Windows/System32/CLUB_testwr.zwo": permission denied.
>
> So, I now see what's going on, thanks for the help in resolving that. :-)
> BUT, I want to keep the script flexible such that whatever directory it's in,
> file writes are to the same directory, I don't want to put a hard path to the directory.
>
> I'm sure it's a simple fix, but can't seem to sort the wood from the trees.

It is a simple fix, and there are two simple ways to fix it.

For Tcl code files, one fix is to make the files you are sourcing into
packages or modules (read the 'package' or 'tm' man pages) and then add
the location of the packages or modules to the auto_path or tm::path add
and then 'package require' the additional code.

The second fix, is to ask Tcl where the main script file is located,
and use that path for opening all the other files. And if you plan to
write files where the script resides, then this is your only option.
To do this you do:

# somewhere early in startup, you grab the directory part of the
# location of the script itself

set script_dir [file dirname [info script]]

# then, everywhere you 'source' a script file or open a file to write
# into, you do this, instead of what you have been doing:

set my_name "CLUB_$woname.zwo" ;# woname is set in an entry box, in this instance as "testwr"
set f_out [open [file join $script_dir $my_name] {WRONLY CREAT TRUNC}]

And your file 'CLUB_$woname.zwo' will be created in the same directory
where your script resides. For accessing/creating files in sub-directories, do:

set f_out [open [file join $script_dir $special_sub_dir $my_name] {WRONLY CREAT TRUNC}]

Note also, when combining paths and filenames, it is best to use
[file join ...] as it will take care of any of the various platform
differences.

Re: File write problem.

<fdcb7015-8bd2-4b5b-b313-3853f5756e3en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:1d4f:b0:6fa:3cf8:b3e2 with SMTP id dm15-20020a05620a1d4f00b006fa3cf8b3e2mr5476813qkb.457.1668271644010;
Sat, 12 Nov 2022 08:47:24 -0800 (PST)
X-Received: by 2002:ae9:e642:0:b0:6ec:2b04:5099 with SMTP id
x2-20020ae9e642000000b006ec2b045099mr5521348qkl.501.1668271643781; Sat, 12
Nov 2022 08:47:23 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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: Sat, 12 Nov 2022 08:47:23 -0800 (PST)
In-Reply-To: <tko4u9$15s47$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: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com>
<b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com>
<yga35ap4qk9.fsf@akutech.de> <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com>
<tkmhfi$v0ra$1@dont-email.me> <739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>
<tko4u9$15s47$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fdcb7015-8bd2-4b5b-b313-3853f5756e3en@googlegroups.com>
Subject: Re: File write problem.
From: nivpars...@gmail.com (snosniv)
Injection-Date: Sat, 12 Nov 2022 16:47:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5743
 by: snosniv - Sat, 12 Nov 2022 16:47 UTC

On Saturday, 12 November 2022 at 12:52:30 UTC, Rich wrote:
> snosniv <nivpa...@gmail.com> wrote:
> > On Friday, 11 November 2022 at 22:14:13 UTC, Rich wrote:
> >> snosniv <nivpa...@gmail.com> wrote:
> >> > BUT, I will try your suggestion as I'd like to know why it worked
> >> > or not depending on how invoked!
>
> >> If you were really trying to load files by relative name (your set
> >> fout_name) above has no directory string, so it is a "relative"
> >> name) then whether the "open" succeeds depends upon what "default
> >> directory" is used to look for the files.
> >>
> >> That "default directory" being the "current working directory" which
> >> you can retreive using the "pwd" command (most likely short for
> >> (P)rint (W)orking (D)irectory).
> >>
> >> Upon startup, your script is assigned a current working directory by
> >> the OS. MSWin seems to like to assign different current working
> >> directories depending upon whether you launch from a cmd shell, a
> >> shortcut, or let windows file extension lookup pick an executable.
> >>
> >> The failures were likely due to MSWin giving you a current working
> >> directory that was different from the directory where your scripts
> >> were stored. So if your scripts were stored at
> >> c:\user\snosiv\script\ but windows gave the process a current
> >> working directory of c:\programs\tcl\bin then all your relative file
> >> accesses were looking in c:\programs\tcl\bin for the filenames your
> >> script was trying to open, and as they were not there, all the opens
> >> failed.
> >
> > Thanks Rich, it's definitely something to do with the path.
> > After a bit of debugging this morning, I invoked my script from where
> > it resides in C:\ActiveTcl\User_files\CYCLE with the "Open with Wish
> > application" after I added the following code:
> >
> >
> > set my_path [pwd]
> > set my_name "CLUB_$woname.zwo" ;# woname is set in an entry box, in this instance as "testwr"
> > set f_out [open $my_path/$my_name w]
> >
> > And I get this message:
> >
> > couldn't open "C:/Windows/System32/CLUB_testwr.zwo": permission denied.
> >
> > So, I now see what's going on, thanks for the help in resolving that. :-)
> > BUT, I want to keep the script flexible such that whatever directory it's in,
> > file writes are to the same directory, I don't want to put a hard path to the directory.
> >
> > I'm sure it's a simple fix, but can't seem to sort the wood from the trees.
> It is a simple fix, and there are two simple ways to fix it.
>
> For Tcl code files, one fix is to make the files you are sourcing into
> packages or modules (read the 'package' or 'tm' man pages) and then add
> the location of the packages or modules to the auto_path or tm::path add
> and then 'package require' the additional code.
>
> The second fix, is to ask Tcl where the main script file is located,
> and use that path for opening all the other files. And if you plan to
> write files where the script resides, then this is your only option.
> To do this you do:
>
> # somewhere early in startup, you grab the directory part of the
> # location of the script itself
>
> set script_dir [file dirname [info script]]
>
> # then, everywhere you 'source' a script file or open a file to write
> # into, you do this, instead of what you have been doing:
> set my_name "CLUB_$woname.zwo" ;# woname is set in an entry box, in this instance as "testwr"
> set f_out [open [file join $script_dir $my_name] {WRONLY CREAT TRUNC}]
>
> And your file 'CLUB_$woname.zwo' will be created in the same directory
> where your script resides. For accessing/creating files in sub-directories, do:
>
> set f_out [open [file join $script_dir $special_sub_dir $my_name] {WRONLY CREAT TRUNC}]
>
> Note also, when combining paths and filenames, it is best to use
> [file join ...] as it will take care of any of the various platform
> differences.

Many thanks for all your help Rich, very kind of you.
Pretty sure I'm just about there now. (I had a silly error with a nested loop, I used the same index for both, "i" DOH!, but now "i" & "j"
bit of a novice error, but this is my first script since retiring July '17! so somewhat rusty to say the least!

Re: File write problem.

<mv10nh5ju26utboa2vtb3nn1ipljuitr2r@4ax.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: hgi...@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: Re: File write problem.
Date: Sat, 12 Nov 2022 22:03:56 +0100
Organization: ratiosoft
Lines: 17
Message-ID: <mv10nh5ju26utboa2vtb3nn1ipljuitr2r@4ax.com>
References: <39c6afdb-8854-4291-8a0c-e62fff30921en@googlegroups.com> <b909f9e7-4389-47d0-b795-6457bb4dc1fan@googlegroups.com> <1d88b61b-6afd-4aef-a033-fdb777a8e84dn@googlegroups.com> <yga35ap4qk9.fsf@akutech.de> <b24a2f42-aea6-42f3-8657-f39ab21d1feen@googlegroups.com> <tkmhfi$v0ra$1@dont-email.me> <739c2a4e-abc5-48a5-99e5-e6751c01e41fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="57d74644377983629d9976744b98cb56";
logging-data="1317058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dO2AHz4SKnOzWJ6ulKICD"
Cancel-Lock: sha1:CLRckKcogS3jFgnX07U+DvnEUq8=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
 by: Helmut Giese - Sat, 12 Nov 2022 21:03 UTC

snosniv <nivparsons@gmail.com> schrieb:

Hi,
say, your script(s) are in c:/some-path/your-directory. Then you are
currently probably in that directory (because you edited some files or
whatever). Then all you need to do is
- open a console in c:/some-path/your-directory
OR
- open a console where ever and navigate to
c:/some-path/your-directory
AND THEN
- type 'wish <your source file>'

This way you start wish with 'c:/some-path/your-directory' as current
directory.
HTH
Helmut

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor