Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You are an insult to my intelligence! I demand that you log off immediately.


devel / comp.lang.tcl / list element in braces followed by "p" instead of space

SubjectAuthor
* list element in braces followed by "p" instead of spaceLuc
`* list element in braces followed by "p" instead of spaceRich
 `- list element in braces followed by "p" instead of spaceheinrichmartin

1
list element in braces followed by "p" instead of space

<20230116211539.49546ba5@lud1.home>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!dU8NMPZdTSqduECtNbhQMA.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: list element in braces followed by "p" instead of space
Date: Mon, 16 Jan 2023 21:15:39 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20230116211539.49546ba5@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="41327"; posting-host="dU8NMPZdTSqduECtNbhQMA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luc - Tue, 17 Jan 2023 00:15 UTC

Code:

----------------------------------------------
set chan [pop3::open -socketcmd tls::socket server.com user password]

set popuidl [::pop3::uidl $chan]
if {[llength $popuidl] == 0} {
puts "nothing"
exit
} puts $popuidl
set popcount [expr [llength $popuidl] / 2]
if {$popcount == 1} {puts "$popcount message\n"}
if {$popcount > 1} {puts "$popcount messages\n"}

set fp [open /path/to/file.txt "a"]
foreach i [seq 1 1 $popcount] {
set popmsg [::pop3::top $chan $i 1000]
array set ::messages "$i $popmsg"
puts $fp "popcheck begin"
puts $fp $popmsg
puts [llength $popmsg]
puts $fp "popcheck end"
} close $fp

parray ::messages
----------------------------------------------

Note: seq is a proc. With 3 messages,
[seq 1 1 $popcount] returns "1 2 3". It's a home-brewn
Tcl version of the Unix shell command.

Two problems, or rather the same problem twice.
I keep getting this error:

----------------------------------------------
list element in braces followed by "p" instead of space
while executing
"array set ::messages "$i $popmsg""
("foreach" body line 3)
invoked from within
"foreach i [seq 1 1 $popcount] {
set popmsg [::pop3::top $chan $i 1000]
array set ::messages "$i $popmsg"
puts $fp "popcheck begin"
puts $fp $pop..."
(file "checkmail.tcl" line 19)
Compilation failed.
----------------------------------------------

By elimination, I see that two lines cause the error:

array set ::messages "$i $popmsg"

puts [llength $popmsg]

If I remove the first line, the second one triggers the
exact same error.

Why?

Note that 'puts $fp $popmsg' correctly appends the
entire header and message to /path/to/file.txt.

--
Luc
>>

Re: list element in braces followed by "p" instead of space

<tq55bm$3309e$1@dont-email.me>

  copy mid

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

  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: list element in braces followed by "p" instead of space
Date: Tue, 17 Jan 2023 03:40:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <tq55bm$3309e$1@dont-email.me>
References: <20230116211539.49546ba5@lud1.home>
Injection-Date: Tue, 17 Jan 2023 03:40:38 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="57f168b5ab6063dce467e3670c5de03e";
logging-data="3244334"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J+k5AQr6/M1vg2cuVHVNq"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:i7hYdDGVwsa/2WJ1dHf/mcGwsRs=
 by: Rich - Tue, 17 Jan 2023 03:40 UTC

Luc <no@no.no> wrote:
> Code:
> set fp [open /path/to/file.txt "a"]
> foreach i [seq 1 1 $popcount] {
> set popmsg [::pop3::top $chan $i 1000]
> array set ::messages "$i $popmsg"
> puts $fp "popcheck begin"
> puts $fp $popmsg
> puts [llength $popmsg]
> puts $fp "popcheck end"
>
> Two problems, or rather the same problem twice.
> I keep getting this error:
>
> ----------------------------------------------
> list element in braces followed by "p" instead of space
> while executing
> "array set ::messages "$i $popmsg""
> ("foreach" body line 3)
> invoked from within
> "foreach i [seq 1 1 $popcount] {
> set popmsg [::pop3::top $chan $i 1000]
> array set ::messages "$i $popmsg"
> puts $fp "popcheck begin"
> puts $fp $pop..."
> (file "checkmail.tcl" line 19)
> Compilation failed.
> ----------------------------------------------
>
> Why?

Array set expects as its second argument a list. You are handing it a
string comprised of the concatenation of $i and the contents of
$popmsg. When you use a string in a context that expects a list, Tcl
attempts to convert that string into a list -- but if the string
contains the wrong special characters in the wrong places, that
conversion into a list fails with exactly this error.

You want to do this for your array set:

array set ::messages [list $i $popmsg]

Then, array set receives a proper list, containing two elements, and
Tcl will not try to convert the contents of the $popmsg string into a
list.

Re: list element in braces followed by "p" instead of space

<b6112af3-b4c4-48cc-9db5-9f9603859fd2n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a37:ef06:0:b0:705:cfba:3af9 with SMTP id j6-20020a37ef06000000b00705cfba3af9mr250026qkk.676.1674030228866;
Wed, 18 Jan 2023 00:23:48 -0800 (PST)
X-Received: by 2002:a81:7487:0:b0:3b7:1b8a:6024 with SMTP id
p129-20020a817487000000b003b71b8a6024mr710686ywc.421.1674030228706; Wed, 18
Jan 2023 00:23:48 -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: Wed, 18 Jan 2023 00:23:48 -0800 (PST)
In-Reply-To: <tq55bm$3309e$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=91.217.55.78; posting-account=Od2xOAoAAACEyRX3Iu5rYt4oevuoeYUG
NNTP-Posting-Host: 91.217.55.78
References: <20230116211539.49546ba5@lud1.home> <tq55bm$3309e$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b6112af3-b4c4-48cc-9db5-9f9603859fd2n@googlegroups.com>
Subject: Re: list element in braces followed by "p" instead of space
From: martin.h...@frequentis.com (heinrichmartin)
Injection-Date: Wed, 18 Jan 2023 08:23:48 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1452
 by: heinrichmartin - Wed, 18 Jan 2023 08:23 UTC

On Tuesday, January 17, 2023 at 4:40:42 AM UTC+1, Rich wrote:
> Luc wrote:
> > Code:
> > [...]
> >
> > Why?
>
> [...]
>
> You want to do this for your array set:
>
> array set ::messages [list $i $popmsg]

.... which should be the same as "set ::messages($i) $popmsg" to state the obvious.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor