Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If it smells it's chemistry, if it crawls it's biology, if it doesn't work it's physics.


devel / comp.lang.tcl / Re: simple loop

SubjectAuthor
* simple loopMark Tarver
`* Re: simple loopBenjamin Riefenstahl
 +- Re: simple loopKenny McCormack
 `* Re: simple loopMark Tarver
  `* Re: simple loopMark Tarver
   `* Re: simple loopMark Tarver
    `* Re: simple loopBenjamin Riefenstahl
     +- Re: simple loopet99
     `* Re: simple loopMark Tarver
      +- Re: simple loopMark Tarver
      `* Re: simple loopRich
       `* Re: simple loopMark Tarver
        `- Re: simple loopRich

1
simple loop

<0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:21ae:b0:680:dce8:a791 with SMTP id t14-20020a05621421ae00b00680dce8a791mr343653qvc.4.1705134588352;
Sat, 13 Jan 2024 00:29:48 -0800 (PST)
X-Received: by 2002:ac8:5814:0:b0:429:c002:1711 with SMTP id
g20-20020ac85814000000b00429c0021711mr25312qtg.7.1705134588143; Sat, 13 Jan
2024 00:29:48 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 13 Jan 2024 00:29:47 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
Subject: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Sat, 13 Jan 2024 08:29:48 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mark Tarver - Sat, 13 Jan 2024 08:29 UTC

This loop is designed to read a file and print the contents.

proc loop {} {
set fd [open "test.txt"]
while { 1 } {
set i [read $fd]
puts $i
}}

However nothing is printed. Ideas why?

Mark

Re: simple loop

<87wmsdierk.fsf@turtle-trading.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: b.riefen...@turtle-trading.net (Benjamin Riefenstahl)
Newsgroups: comp.lang.tcl
Subject: Re: simple loop
Date: Sat, 13 Jan 2024 13:44:47 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <87wmsdierk.fsf@turtle-trading.net>
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="09338bf8d9fb6710f92672f06a57ff07";
logging-data="4143657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PA7kKTWYy7GkmC76tpSzzEiIEFZ2dmqw="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:t028UOZM/VOGsE2L5f93DmgcLOQ=
sha1:bb4jnRVWIZ+s/4Ze+pGLVRl3HKU=
 by: Benjamin Riefenstahl - Sat, 13 Jan 2024 12:44 UTC

Hi Mark,

Mark Tarver writes:
> proc loop {} {
> set fd [open "test.txt"]
> while { 1 } {
> set i [read $fd]
> puts $i
> }}
>
> However nothing is printed. Ideas why?

Works fine here. In the first run through the loop "read" without the
"size" parameter reads the whole file and "puts" prints it. For the
rest of your infinite loop, "read" does not have anything to read, but
"puts" continues to write empty lines. So if you run this proc in a
terminal or Windows console, while the screen is empty in fact the
program is busy printing newlines all the time.

HTH, benny

Re: simple loop

<unu1j5$1vvjp$2@news.xmission.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!1.us.feeder.erje.net!feeder.erje.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl
Subject: Re: simple loop
Date: Sat, 13 Jan 2024 13:01:25 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <unu1j5$1vvjp$2@news.xmission.com>
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com> <87wmsdierk.fsf@turtle-trading.net>
Injection-Date: Sat, 13 Jan 2024 13:01:25 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2096761"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 13 Jan 2024 13:01 UTC

In article <87wmsdierk.fsf@turtle-trading.net>,
Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net> wrote:
>Hi Mark,
>
>Mark Tarver writes:
>> proc loop {} {
>> set fd [open "test.txt"]
>> while { 1 } {
>> set i [read $fd]
>> puts $i
>> }}
>>
>> However nothing is printed. Ideas why?
>
>Works fine here. In the first run through the loop "read" without the
>"size" parameter reads the whole file and "puts" prints it. For the
>rest of your infinite loop, "read" does not have anything to read, but
>"puts" continues to write empty lines. So if you run this proc in a
>terminal or Windows console, while the screen is empty in fact the
>program is busy printing newlines all the time.
>
>HTH, benny

OP probably meant to use "gets" instead of "read", and to make the "gets"
command be the condition of the while loop, so that it exits when it hits
EOF.

--
He continues to assert that 2 plus 2 equals 4, despite being repeatedly
told otherwise.

Re: simple loop

<74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:5bce:0:b0:67f:2cd6:85d0 with SMTP id t14-20020ad45bce000000b0067f2cd685d0mr182811qvt.11.1705152586014;
Sat, 13 Jan 2024 05:29:46 -0800 (PST)
X-Received: by 2002:a05:6214:2261:b0:67f:ce3a:14be with SMTP id
gs1-20020a056214226100b0067fce3a14bemr423968qvb.0.1705152585814; Sat, 13 Jan
2024 05:29:45 -0800 (PST)
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.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: Sat, 13 Jan 2024 05:29:45 -0800 (PST)
In-Reply-To: <87wmsdierk.fsf@turtle-trading.net>
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com> <87wmsdierk.fsf@turtle-trading.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
Subject: Re: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Sat, 13 Jan 2024 13:29:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2112
 by: Mark Tarver - Sat, 13 Jan 2024 13:29 UTC

On Saturday 13 January 2024 at 12:44:58 UTC, Benjamin Riefenstahl wrote:
> Hi Mark,
> Mark Tarver writes:
> > proc loop {} {
> > set fd [open "test.txt"]
> > while { 1 } {
> > set i [read $fd]
> > puts $i
> > }}
> >
> > However nothing is printed. Ideas why?
> Works fine here. In the first run through the loop "read" without the
> "size" parameter reads the whole file and "puts" prints it. For the
> rest of your infinite loop, "read" does not have anything to read, but
> "puts" continues to write empty lines. So if you run this proc in a
> terminal or Windows console, while the screen is empty in fact the
> program is busy printing newlines all the time.
>
> HTH, benny

That's what I expected to happen. One print of 'Hello World' and then a lot of
nothings. I'm using WISH and nothing is printed in the
console window. I did mean to use read and not gets. This is supposed to be a precursor
to a program that does something more useful.

Mark

Re: simple loop

<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:4ea4:0:b0:681:555b:68fd with SMTP id ed4-20020ad44ea4000000b00681555b68fdmr43553qvb.3.1705153083667;
Sat, 13 Jan 2024 05:38:03 -0800 (PST)
X-Received: by 2002:ad4:5c64:0:b0:67f:c3d:f7c3 with SMTP id
i4-20020ad45c64000000b0067f0c3df7c3mr92469qvh.6.1705153083457; Sat, 13 Jan
2024 05:38:03 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 13 Jan 2024 05:38:03 -0800 (PST)
In-Reply-To: <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com>
Subject: Re: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Sat, 13 Jan 2024 13:38:03 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mark Tarver - Sat, 13 Jan 2024 13:38 UTC

The more useful is

proc loop {} {
set fd [open "test.txt"]
while { 1 } {
set i [read $fd]
<if $i is not empty ;; pseudocode
evaluate $i
else skip>
}}
I wonder if the output is being buffered in some ay and that's why I am not seeing anything.

Mark

Re: simple loop

<5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:300a:b0:680:b2a1:1c42 with SMTP id ke10-20020a056214300a00b00680b2a11c42mr207084qvb.0.1705155941634;
Sat, 13 Jan 2024 06:25:41 -0800 (PST)
X-Received: by 2002:a05:622a:1913:b0:429:9970:4a94 with SMTP id
w19-20020a05622a191300b0042999704a94mr77274qtc.1.1705155941312; Sat, 13 Jan
2024 06:25:41 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.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, 13 Jan 2024 06:25:41 -0800 (PST)
In-Reply-To: <b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>
Subject: Re: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Sat, 13 Jan 2024 14:25:41 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1534
 by: Mark Tarver - Sat, 13 Jan 2024 14:25 UTC

This is odd.

proc loop {} {
set fd [open "C:/Users/shend/OneDrive/Desktop/test.txt"]
while { 1 } {
set i [read $fd]
puts "hello"
}}

should just keep printing 'hello'. This works under the console
only TCL/tk but not under WISH. Any ideas?

Mark

Re: simple loop

<87edeltg9n.fsf@turtle-trading.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: b.riefen...@turtle-trading.net (Benjamin Riefenstahl)
Newsgroups: comp.lang.tcl
Subject: Re: simple loop
Date: Sat, 13 Jan 2024 16:16:52 +0100
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <87edeltg9n.fsf@turtle-trading.net>
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net>
<74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com>
<5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f3ad0db6310c4475b59e58395e95ab76";
logging-data="4186002"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DJ9xxE46/XzsRphC/0VhButwG4MsaWGI="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:z8zQuT18prfzQVJwrYxMlemjS2g=
sha1:ei9nD9JfBOqQXko+ek0tuBhXGgc=
 by: Benjamin Riefenstahl - Sat, 13 Jan 2024 15:16 UTC

Hi Mark.

Mark Tarver writes:
> proc loop {} {
> set fd [open "C:/Users/shend/OneDrive/Desktop/test.txt"]
> while { 1 } {
> set i [read $fd]
> puts "hello"
> }}
>
> should just keep printing 'hello'. This works under the console only
> TCL/tk but not under WISH. Any ideas?

You are using the graphical Tk console. A graphical console will not do
anything unless you start a message loop ("vwait"). An endless loop is
not usefull here, because the message loop can not run at the same time.

HTH, benny

Re: simple loop

<uo2f8s$qnb2$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et9...@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: simple loop
Date: Sun, 14 Jan 2024 21:19:23 -0800
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <uo2f8s$qnb2$1@dont-email.me>
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net>
<74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com>
<5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>
<87edeltg9n.fsf@turtle-trading.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 15 Jan 2024 05:19:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d2adc6e1a27d1f5dc21bc49732c7ad2f";
logging-data="875874"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZwVI4pn0srwNNgNQBqOsw"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:h4t9/V+t1hJXO0UiqSbxTMOJ3S8=
Content-Language: en-US
In-Reply-To: <87edeltg9n.fsf@turtle-trading.net>
 by: et99 - Mon, 15 Jan 2024 05:19 UTC

On 1/13/2024 7:16 AM, Benjamin Riefenstahl wrote:
> Hi Mark.
>
> Mark Tarver writes:
>> proc loop {} {
>> set fd [open "C:/Users/shend/OneDrive/Desktop/test.txt"]
>> while { 1 } {
>> set i [read $fd]
>> puts "hello"
>> }}
>>
>> should just keep printing 'hello'. This works under the console only
>> TCL/tk but not under WISH. Any ideas?
>
> You are using the graphical Tk console. A graphical console will not do
> anything unless you start a message loop ("vwait"). An endless loop is
> not usefull here, because the message loop can not run at the same time.
>
> HTH, benny

The OP didn't mention how he ran this program. Did he put that code in a file and

> wish <file>

or did he run with an interactive wish, type in the proc etc.

Ordinarily, if you wish <file> it won't open the console, just a toplevel of . (dot).

To see what is going on, I suggest changing the puts to,

puts "[incr count] hello";update

And add a [console show] at the top.

Re: simple loop

<c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:2261:b0:67f:ce3a:14be with SMTP id gs1-20020a056214226100b0067fce3a14bemr876877qvb.0.1705319683906;
Mon, 15 Jan 2024 03:54:43 -0800 (PST)
X-Received: by 2002:a05:6214:518b:b0:67f:74c8:70de with SMTP id
kl11-20020a056214518b00b0067f74c870demr397037qvb.5.1705319683644; Mon, 15 Jan
2024 03:54:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Mon, 15 Jan 2024 03:54:43 -0800 (PST)
In-Reply-To: <87edeltg9n.fsf@turtle-trading.net>
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com> <5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>
<87edeltg9n.fsf@turtle-trading.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com>
Subject: Re: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Mon, 15 Jan 2024 11:54:43 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2805
 by: Mark Tarver - Mon, 15 Jan 2024 11:54 UTC

OK; a bit further on. I've not really looked at TLC/tk for a long time.

Basically I want TCL/tk to enter a loop and read a file. When the file contains a TCL/tk command, This command should be read and executed.
It works fine for commands like 'bell' and 'puts' and fails for widget commands. However when the event loop is existed, the missing
widgets appear. So there is some form of buffering going on. If so, is there a way of flushing this buffer?

I cite the program below.

Mark

set in {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/shen-to-tcl.txt}
set out {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/tcl-to-shen.txt}

proc eventloop {File} {
while { 1 } {
after 10
if { [newcommand? $File] } {
enact $File }
}}

proc newcommand? {File} {
set Source [open $File r]
set Data [read $Source]
set Verdict [eot? $Data]
close $Source
return $Verdict}

proc eot? {S} {
return [ string match *eot $S ]
}

proc enact {File} {
set Source [open $File r]
set Data [read $Source]
set Command [trim $Data]
overwrite $File
eval $Command
close $Source}

proc overwrite {File} {
set Sink [open $File w]
puts -nonewline $Sink ""
flush $Sink
close $Sink}

proc trim {S} {
return [string map {"eot" ""} $S]
}

proc send {String} {
set Sink [open $out w]
puts [concat String "eot"] Sink
close $Sink}

eventloop $in

Re: simple loop

<ba4c962b-28f1-40f7-81b0-1c55f02631ccn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:45ab:0:b0:681:5534:6c38 with SMTP id y11-20020ad445ab000000b0068155346c38mr245393qvu.7.1705320052530;
Mon, 15 Jan 2024 04:00:52 -0800 (PST)
X-Received: by 2002:ad4:5def:0:b0:681:6488:d299 with SMTP id
jn15-20020ad45def000000b006816488d299mr92878qvb.8.1705320052327; Mon, 15 Jan
2024 04:00:52 -0800 (PST)
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.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: Mon, 15 Jan 2024 04:00:52 -0800 (PST)
In-Reply-To: <c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com> <5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>
<87edeltg9n.fsf@turtle-trading.net> <c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba4c962b-28f1-40f7-81b0-1c55f02631ccn@googlegroups.com>
Subject: Re: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Mon, 15 Jan 2024 12:00:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3102
 by: Mark Tarver - Mon, 15 Jan 2024 12:00 UTC

On Monday 15 January 2024 at 11:54:46 UTC, Mark Tarver wrote:
> OK; a bit further on. I've not really looked at TLC/tk for a long time.
>
> Basically I want TCL/tk to enter a loop and read a file. When the file contains a TCL/tk command, This command should be read and executed.
> It works fine for commands like 'bell' and 'puts' and fails for widget commands. However when the event loop is existed, the missing
> widgets appear. So there is some form of buffering going on. If so, is there a way of flushing this buffer?
>
> I cite the program below.
>
> Mark
>
> set in {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/shen-to-tcl.txt}
> set out {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/tcl-to-shen.txt}
>
> proc eventloop {File} {
> while { 1 } {
> after 10
> if { [newcommand? $File] } {
> enact $File }
> }}
>
> proc newcommand? {File} {
> set Source [open $File r]
> set Data [read $Source]
> set Verdict [eot? $Data]
> close $Source
> return $Verdict}
>
> proc eot? {S} {
> return [ string match *eot $S ]
> }
>
> proc enact {File} {
> set Source [open $File r]
> set Data [read $Source]
> set Command [trim $Data]
> overwrite $File
> eval $Command
> close $Source}
>
> proc overwrite {File} {
> set Sink [open $File w]
> puts -nonewline $Sink ""
> flush $Sink
> close $Sink}
>
> proc trim {S} {
> return [string map {"eot" ""} $S]
> }
>
> proc send {String} {
> set Sink [open $out w]
> puts [concat String "eot"] Sink
> close $Sink}
>
> eventloop $in

For example, is it possible to embed an event loop in a thread as a background process and solve the problem that way?

Mark

Re: simple loop

<uo3d9t$um0i$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: simple loop
Date: Mon, 15 Jan 2024 13:51:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <uo3d9t$um0i$1@dont-email.me>
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com> <87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com> <b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com> <5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com> <87edeltg9n.fsf@turtle-trading.net> <c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com>
Injection-Date: Mon, 15 Jan 2024 13:51:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d55582f397a635c313377af21dc5de42";
logging-data="1005586"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fUCzMYSjFWri6Drh5gH6C"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:6OM13BiwKn8lLVNzhtHFuMMb3zw=
 by: Rich - Mon, 15 Jan 2024 13:51 UTC

Mark Tarver <dr.mtarver@gmail.com> wrote:
> OK; a bit further on. I've not really looked at TLC/tk for a long time.
>
> Basically I want TCL/tk to enter a loop and read a file. When the
> file contains a TCL/tk command, This command should be read and
> executed.

Are you looking for the existing [source] command?

> It works fine for commands like 'bell' and 'puts' and fails for
> widget commands. However when the event loop is existed, the missing
> widgets appear.

This is normal. Most of the work of displaying widgets is performed on
the event loop as a background task. So if your Tcl code never returns
to the event loop, that work does not get performed.

Note that [bell] and [puts] are Tcl commands, not Tk commands, so they
do not interact with the event loop.

> So there is some form of buffering going on.

Yes, much of the work is deferred to be run during "idle time" (time
when your Tcl script code is not running) of the GUI program.

> If so, is there a way of flushing this buffer?

The [update] command is provided for just this purpose, but can have
other side effects
(https://wiki.tcl-lang.org/page/Update%20considered%20harmful).

> I cite the program below.
>
> Mark
>
> set in {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/shen-to-tcl.txt}
> set out {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/tcl-to-shen.txt}
>
> proc eventloop {File} {
> while { 1 } {
> after 10
> if { [newcommand? $File] } {
> enact $File }
> }}

Never returns, and contains no calls to [update] no the event loop
never gets to run, and all the deferred work is never performed.

Re: simple loop

<232763e0-1fbb-44af-ae72-bd890a9533cfn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:224:b0:681:554a:a94c with SMTP id j4-20020a056214022400b00681554aa94cmr424261qvt.3.1705339359681;
Mon, 15 Jan 2024 09:22:39 -0800 (PST)
X-Received: by 2002:a05:6214:202:b0:681:554a:a943 with SMTP id
i2-20020a056214020200b00681554aa943mr495052qvt.10.1705339359331; Mon, 15 Jan
2024 09:22:39 -0800 (PST)
Path: i2pn2.org!i2pn.org!nntp.comgw.net!usenet.blueworldhosting.com!diablo1.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: Mon, 15 Jan 2024 09:22:39 -0800 (PST)
In-Reply-To: <uo3d9t$um0i$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=86.28.97.229; posting-account=kJbRXgoAAADVvCa8xCOuqxtZ-KSaXUAS
NNTP-Posting-Host: 86.28.97.229
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com>
<87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com>
<b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com> <5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com>
<87edeltg9n.fsf@turtle-trading.net> <c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com>
<uo3d9t$um0i$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <232763e0-1fbb-44af-ae72-bd890a9533cfn@googlegroups.com>
Subject: Re: simple loop
From: dr.mtar...@gmail.com (Mark Tarver)
Injection-Date: Mon, 15 Jan 2024 17:22:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3221
 by: Mark Tarver - Mon, 15 Jan 2024 17:22 UTC

On Monday 15 January 2024 at 13:52:02 UTC, Rich wrote:
> Mark Tarver <dr.mt...@gmail.com> wrote:
> > OK; a bit further on. I've not really looked at TLC/tk for a long time.
> >
> > Basically I want TCL/tk to enter a loop and read a file. When the
> > file contains a TCL/tk command, This command should be read and
> > executed.
> Are you looking for the existing [source] command?
> > It works fine for commands like 'bell' and 'puts' and fails for
> > widget commands. However when the event loop is existed, the missing
> > widgets appear.
> This is normal. Most of the work of displaying widgets is performed on
> the event loop as a background task. So if your Tcl code never returns
> to the event loop, that work does not get performed.
>
> Note that [bell] and [puts] are Tcl commands, not Tk commands, so they
> do not interact with the event loop.
> > So there is some form of buffering going on.
> Yes, much of the work is deferred to be run during "idle time" (time
> when your Tcl script code is not running) of the GUI program.
> > If so, is there a way of flushing this buffer?
> The [update] command is provided for just this purpose, but can have
> other side effects
> (https://wiki.tcl-lang.org/page/Update%20considered%20harmful).
> > I cite the program below.
> >
> > Mark
> >
> > set in {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/shen-to-tcl.txt}
> > set out {C:/Users/shend/OneDrive/Desktop/Shen/S37.2/tcl-to-shen.txt}
> >
> > proc eventloop {File} {
> > while { 1 } {
> > after 10
> > if { [newcommand? $File] } {
> > enact $File }
> > }}
> Never returns, and contains no calls to [update] no the event loop
> never gets to run, and all the deferred work is never performed.

Thanks 'update' was a great help.

Mark

Re: simple loop

<uo3qlr$10tck$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: simple loop
Date: Mon, 15 Jan 2024 17:40:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <uo3qlr$10tck$1@dont-email.me>
References: <0f80307f-953a-4897-bbf4-b24a935c5f0an@googlegroups.com> <87wmsdierk.fsf@turtle-trading.net> <74c5ce7a-16b7-470f-b73d-1c66550f3a6cn@googlegroups.com> <b9825954-17db-4e41-b8b3-6cc5b8bafb9dn@googlegroups.com> <5d489e1b-479f-47fa-a36b-3d8abc1d276fn@googlegroups.com> <87edeltg9n.fsf@turtle-trading.net> <c1197cec-c45a-44b3-a533-43a3936fade7n@googlegroups.com> <uo3d9t$um0i$1@dont-email.me> <232763e0-1fbb-44af-ae72-bd890a9533cfn@googlegroups.com>
Injection-Date: Mon, 15 Jan 2024 17:40:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d55582f397a635c313377af21dc5de42";
logging-data="1078676"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MKhBEU3qW4JcfOTUmt+Hz"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:ZBJDy2/292r38GjYgt+SDROpx1Y=
 by: Rich - Mon, 15 Jan 2024 17:40 UTC

Mark Tarver <dr.mtarver@gmail.com> wrote:
> On Monday 15 January 2024 at 13:52:02 UTC, Rich wrote:
>> Mark Tarver <dr.mt...@gmail.com> wrote:
>> > proc eventloop {File} {
>> > while { 1 } {
>> > after 10
>> > if { [newcommand? $File] } {
>> > enact $File }
>> > }}
>> Never returns, and contains no calls to [update] no the event loop
>> never gets to run, and all the deferred work is never performed.
>
> Thanks 'update' was a great help.

Do read https://wiki.tcl-lang.org/page/Update%20considered%20harmful

Forcibly calling update can cause issues in some instances. If you are
truly trying to make a proper GUI (as opposed to just experimenting
with ideas) then letting the event loop run normally, and structuring
your code to react to events (i.e., don't sit in an endless loop), will
produce more robust code and avoid many of the bad side effects.

That 'endless loop' example you gave looks an awful lot like the
general structure of traditional Win32 programs. If you are trying to
write the same code structure you'd write for a Win32 program, then it
is better to rethink that structure. The endless loop method is not
only unnecessary for Tk, it is detrimental to the basic way Tk works.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor