Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.lang.tcl / I can't parray in a text widget

SubjectAuthor
* I can't parray in a text widgetLuc
+* I can't parray in a text widgetHelmut Giese
|+* I can't parray in a text widgetLuc
||+- I can't parray in a text widgetRalf Fassel
||`* I can't parray in a text widgetChristian Gollwitzer
|| `* I can't parray in a text widgetLuc
||  `- I can't parray in a text widgetRalf Fassel
|+- I can't parray in a text widgetet4
|`- I can't parray in a text widgetMike Griffiths
+- I can't parray in a text widgetRobert Heller
`- I can't parray in a text widgetRich

1
I can't parray in a text widget

<20221116114256.2b66ac12@lud1.home>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!5fNieJ10Veff9nzZBR7qpg.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: I can't parray in a text widget
Date: Wed, 16 Nov 2022 11:42:56 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221116114256.2b66ac12@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="36316"; posting-host="5fNieJ10Veff9nzZBR7qpg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
 by: Luc - Wed, 16 Nov 2022 14:42 UTC

I am really struggling with this:

--------------------
package require Tk

text .t -width 40 -height 6 -font "FreeSans 18"
pack .t

array set file_1 {name file1 date today size 100k}
array set file_2 {name file2 date today size 200k}
array set file_3 {name file3 date today size 300k}

proc p.printfiles argNumber {
.t delete 1.0 end
.t insert end ::file_$argNumber
.t insert end "\n"
.t insert end "parray: [parray ::file_$argNumber]"
.t insert end "[set ::file_[set argNumber](size)]"
parray ::file_$argNumber
}

p.printfiles 2
--------------------

Result:
::file_2
argNumber
parray:
200k

I've tried all kinds of formats and escaping and can't get the code to
insert the output of [parray] into the text widget.

And the plot thickens. If I include [info vars] in those insert lines, the
only var it finds is argNumber. What about the global vars? Where are they?

Maybe that is why it can't print [parray]?

No, that is not the reason because

1) the parray line at the end works fine in stdout.

2) this line works as expected:

..t insert end "[set ::file_[set argNumber](size)]"

What am I doing wrong?

--
Luc
>>

Re: I can't parray in a text widget

<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>

  copy mid

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

  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: I can't parray in a text widget
Date: Wed, 16 Nov 2022 16:29:13 +0100
Organization: ratiosoft
Lines: 12
Message-ID: <tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
References: <20221116114256.2b66ac12@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="a88f7ee9c92485a67503e48bfd586b46";
logging-data="2512149"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nI1GwtCaq1Hw8k3OPAPJE"
Cancel-Lock: sha1:qc3g7DSz3KSUoCs4b8ExIEyq0gk=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
 by: Helmut Giese - Wed, 16 Nov 2022 15:29 UTC

Hi Luc,
no, you cannot 'parray into a text widget':
'parray' writes to stdout and a text widget wants
'$t insert <index where> <text>'.
I think the simplest solution is:
- look into the file 'parray.tcl' (on my installation it is located in
<path to my installation>/lib/tcl8.6
- rename the parray function, add another parameter to it
and replace the line 'puts stdout ...' with '$t insert ...'

HTH
Helmut

Re: I can't parray in a text widget

<20221116125430.13a1188d@lud1.home>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!5fNieJ10Veff9nzZBR7qpg.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: I can't parray in a text widget
Date: Wed, 16 Nov 2022 12:54:30 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221116125430.13a1188d@lud1.home>
References: <20221116114256.2b66ac12@lud1.home>
<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62296"; posting-host="5fNieJ10Veff9nzZBR7qpg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
 by: Luc - Wed, 16 Nov 2022 15:54 UTC

On Wed, 16 Nov 2022 16:29:13 +0100, Helmut Giese wrote:

> Hi Luc,
> no, you cannot 'parray into a text widget':
> 'parray' writes to stdout and a text widget wants
> '$t insert <index where> <text>'.
> I think the simplest solution is:
> - look into the file 'parray.tcl' (on my installation it is located in
> <path to my installation>/lib/tcl8.6
> - rename the parray function, add another parameter to it
> and replace the line 'puts stdout ...' with '$t insert ...'
>
> HTH
> Helmut

OK, I had a wrong understanding of parray.

Thank you for the clarifications.

I am doing

foreach i [array names ::file_$argNumber] {
.t insert end "[set ::file_[set argNumber]($i)]\n"
}

A little ugly and hard to read, but it works.

Thank you.

--
Luc
>>

Re: I can't parray in a text widget

<jg2dndXE2uRfkOj-nZ2dnZfqn_ednZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!69.80.99.23.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 16 Nov 2022 16:20:18 +0000
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: I can't parray in a text widget
In-Reply-To: <20221116114256.2b66ac12@lud1.home>
References: <20221116114256.2b66ac12@lud1.home>
Newsgroups: comp.lang.tcl
Content-Type: text/plain; charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <jg2dndXE2uRfkOj-nZ2dnZfqn_ednZ2d@giganews.com>
Date: Wed, 16 Nov 2022 16:20:18 +0000
Lines: 77
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-jszENiPiENcoFeQaRgxd/1dpRiaA3hbygI8njwPLwPiS9AeUWc86ba75l5crbPoQWxsvREVm+ATMGfJ!FTfq69ZVe5vMVq31LjeIxi6JzjZ4+gySkpj1WDWbk2anUQKB2Tmjng+hY2t01q35qK4mt8HEigJl!gDw=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
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
X-Received-Bytes: 3523
 by: Robert Heller - Wed, 16 Nov 2022 16:20 UTC

At Wed, 16 Nov 2022 11:42:56 -0300 Luc <no@no.no> wrote:

>
> I am really struggling with this:
>
> --------------------
> package require Tk
>
> text .t -width 40 -height 6 -font "FreeSans 18"
> pack .t
>
> array set file_1 {name file1 date today size 100k}
> array set file_2 {name file2 date today size 200k}
> array set file_3 {name file3 date today size 300k}
>
> proc p.printfiles argNumber {
> .t delete 1.0 end
> .t insert end ::file_$argNumber
> .t insert end "\n"
> .t insert end "parray: [parray ::file_$argNumber]"
> .t insert end "[set ::file_[set argNumber](size)]"
> parray ::file_$argNumber
> }
>
> p.printfiles 2
> --------------------
>
> Result:
> ::file_2
> argNumber
> parray:
> 200k
>
> I've tried all kinds of formats and escaping and can't get the code to
> insert the output of [parray] into the text widget.
>
>
> And the plot thickens. If I include [info vars] in those insert lines, the
> only var it finds is argNumber. What about the global vars? Where are they?
>
> Maybe that is why it can't print [parray]?
>
> No, that is not the reason because
>
> 1) the parray line at the end works fine in stdout.
>
> 2) this line works as expected:
>
> .t insert end "[set ::file_[set argNumber](size)]"
>
> What am I doing wrong?

The parray function is *hard wired* to *print* an array to stdout. It is
really only meant to debugging use. You will need to write your own
parray-like proc to insert the array into the text widget in the format you
like. Maybe something like:

proc insertArray {textwidget arrayname {pattern *}} {
upvar $arrayname array
set l 0
foreach k [array names array $pattern] {
set l [expr {max($l,[string length $k])}]
}
foreach k [array names array $pattern] {
set space [string repeat " " [expr {$l-[string length $k]}]]
$textwidget insert end [format "%s(%s)%s = %s\n" \
$arrayname $k "$space" $array($k)]
}
}

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: I can't parray in a text widget

<ygaa64qc19t.fsf@akutech.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: I can't parray in a text widget
Date: Wed, 16 Nov 2022 17:27:58 +0100
Lines: 16
Message-ID: <ygaa64qc19t.fsf@akutech.de>
References: <20221116114256.2b66ac12@lud1.home>
<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
<20221116125430.13a1188d@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net egc68UyLeXFgepC4gFhrcAivCIJnT2TJIKwYzO1X4uTgu/b1A=
Cancel-Lock: sha1:KrfFRVZ97d1oKE7D9a29rMytAgQ= sha1:oSDIE/4eFll+UtQiWotpW+O7s8o=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Wed, 16 Nov 2022 16:27 UTC

* Luc <no@no.no>
| foreach i [array names ::file_$argNumber] {
| .t insert end "[set ::file_[set argNumber]($i)]\n"
| }
>
| A little ugly and hard to read, but it works.

May I suggest

foreach {key val} [array get ::file_$argNumber] {
.t insert end "$val\n"
}

Prettier, IMHO ;-)

R'

Re: I can't parray in a text widget

<tl3380$2cvgb$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: aurio...@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: I can't parray in a text widget
Date: Wed, 16 Nov 2022 17:30:56 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <tl3380$2cvgb$1@dont-email.me>
References: <20221116114256.2b66ac12@lud1.home>
<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
<20221116125430.13a1188d@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 16 Nov 2022 16:30:56 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="7855ea70f6c7f02cdd954563f8410f61";
logging-data="2522635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MhcyyrH5riNAGTyyuUMQzAteg3HoZKZo="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:102.0)
Gecko/20100101 Thunderbird/102.4.2
Cancel-Lock: sha1:eD89uEWhnRe3fctdXqlJ+0yVmF8=
In-Reply-To: <20221116125430.13a1188d@lud1.home>
 by: Christian Gollwitzer - Wed, 16 Nov 2022 16:30 UTC

Am 16.11.22 um 16:54 schrieb Luc:
> Thank you for the clarifications.
>
> I am doing
>
> foreach i [array names ::file_$argNumber] {
> .t insert end "[set ::file_[set argNumber]($i)]\n"
> }
>
> A little ugly and hard to read, but it works.

In order to iterate over an array, you can also use array get:

foreach {key val} [array get yourarray] {
puts "$key = $val"
}

which should be more readable.

Christian

Re: I can't parray in a text widget

<20221116141644.7442bee3@lud1.home>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!5fNieJ10Veff9nzZBR7qpg.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: I can't parray in a text widget
Date: Wed, 16 Nov 2022 14:16:44 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221116141644.7442bee3@lud1.home>
References: <20221116114256.2b66ac12@lud1.home>
<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
<20221116125430.13a1188d@lud1.home>
<tl3380$2cvgb$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="7671"; posting-host="5fNieJ10Veff9nzZBR7qpg.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 - Wed, 16 Nov 2022 17:16 UTC

On Wed, 16 Nov 2022 17:30:56 +0100, Christian Gollwitzer wrote:

> Am 16.11.22 um 16:54 schrieb Luc:
> > Thank you for the clarifications.
> >
> > I am doing
> >
> > foreach i [array names ::file_$argNumber] {
> > .t insert end "[set ::file_[set argNumber]($i)]\n"
> > }
> >
> > A little ugly and hard to read, but it works.
>
> In order to iterate over an array, you can also use array get:
>
> foreach {key val} [array get yourarray] {
> puts "$key = $val"
> }
>
> which should be more readable.
>
> Christian

Yes, I wrote my own syntatic sugar:

proc p.fileinfo {argNumber argInfo} {
if {$argInfo == "all"} {
return "[set ::files_[set argNumber](name) \
[set ::files_[set argNumber](size) \
[set ::files_[set argNumber](datetime) \
[set ::files_[set argNumber](type) \
[set ::files_[set argNumber](permission)"
}
return "[set ::files_[set argNumber]($argInfo)]"
}

% puts [p.fileinfo 15 size]
256636

Thank you again!

--
Luc
>>

Re: I can't parray in a text widget

<tl36rs$2d9b9$1@dont-email.me>

  copy mid

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

  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: I can't parray in a text widget
Date: Wed, 16 Nov 2022 17:32:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <tl36rs$2d9b9$1@dont-email.me>
References: <20221116114256.2b66ac12@lud1.home>
Injection-Date: Wed, 16 Nov 2022 17:32:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="fb991ff29593f044d3f6b32b30a70faf";
logging-data="2532713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rYqo+tuS2AcsclPSLtpVV"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:6y24+eSh/texDRybVQ6/6NCJXXE=
 by: Rich - Wed, 16 Nov 2022 17:32 UTC

Luc <no@no.no> wrote:
> proc p.printfiles argNumber {
> .t delete 1.0 end
> .t insert end ::file_$argNumber
> .t insert end "\n"
> .t insert end "parray: [parray ::file_$argNumber]"
> .t insert end "[set ::file_[set argNumber](size)]"
> parray ::file_$argNumber
> }
>
> And the plot thickens. If I include [info vars] in those insert
> lines, the only var it finds is argNumber. What about the global
> vars? Where are they?

As no one has yet answer this, I'll add.

The reason 'info vars' only shows argNumber is because this is how
'info vars' is defined to behave:

man n info:

info vars ?pattern?
If pattern is not specified, returns a list of all the
names of currently-visible variables. This includes
locals and currently-visible globals. ...

Do recall that in Tcl, global variables are not visible inside proc's
by default. Since your proc has a single arg (argNumber) and no calls
to "global" to make any globals visible, the only 'currently-visible
variables' inside the proc is the single 'argNumber'.

If you want to see all the globals, you have to ask for all the
globals:

man n info:

info globals ?pattern?
If pattern is not specified, returns a list of all the
names of currently-defined global variables. Global
variables are variables in the global namespace. ...

You want 'info globals' if you want to see all the globals from inside
a proc.

Re: I can't parray in a text widget

<tl3g0t$1nua$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!YN2ulY6LKp1eoOUw2OJ8ig.user.46.165.242.91.POSTED!not-for-mail
From: tcln...@rocketship1.me (et4)
Newsgroups: comp.lang.tcl
Subject: Re: I can't parray in a text widget
Date: Wed, 16 Nov 2022 12:09:01 -0800
Organization: Aioe.org NNTP Server
Message-ID: <tl3g0t$1nua$1@gioia.aioe.org>
References: <20221116114256.2b66ac12@lud1.home>
<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="57290"; posting-host="YN2ulY6LKp1eoOUw2OJ8ig.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: et4 - Wed, 16 Nov 2022 20:09 UTC

On 11/16/2022 7:29 AM, Helmut Giese wrote:

> - look into the file 'parray.tcl' (on my installation it is located in
> <path to my installation>/lib/tcl8.6

Regarding parray, it also nicely formats the output and takes a pattern.

It also does a sort, however I find it's a bit ugly IMHO with numerical indices. So, I modify it to use a -dictionary sort rather than the default -ascii where 10 sorts before 2.

Re: I can't parray in a text widget

<0ee35847-fbc6-470f-ba2e-e73430637f9bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:480b:b0:3a5:6aa1:7cd6 with SMTP id fb11-20020a05622a480b00b003a56aa17cd6mr23174625qtb.146.1668635154777;
Wed, 16 Nov 2022 13:45:54 -0800 (PST)
X-Received: by 2002:a05:6214:2b9e:b0:4c6:382c:3d78 with SMTP id
kr30-20020a0562142b9e00b004c6382c3d78mr15205926qvb.102.1668635154633; Wed, 16
Nov 2022 13:45:54 -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, 16 Nov 2022 13:45:54 -0800 (PST)
In-Reply-To: <tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
Injection-Info: google-groups.googlegroups.com; posting-host=81.99.101.178; posting-account=hbOuAgoAAACCTxHaAgRboJbA2XUYvKy2
NNTP-Posting-Host: 81.99.101.178
References: <20221116114256.2b66ac12@lud1.home> <tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0ee35847-fbc6-470f-ba2e-e73430637f9bn@googlegroups.com>
Subject: Re: I can't parray in a text widget
From: mik...@keyboardzombie.com (Mike Griffiths)
Injection-Date: Wed, 16 Nov 2022 21:45:54 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2177
 by: Mike Griffiths - Wed, 16 Nov 2022 21:45 UTC

On Wednesday, 16 November 2022 at 15:29:17 UTC, Helmut Giese wrote:
> Hi Luc,
> no, you cannot 'parray into a text widget':
> 'parray' writes to stdout and a text widget wants
> '$t insert <index where> <text>'.
> I think the simplest solution is:
> - look into the file 'parray.tcl' (on my installation it is located in
> <path to my installation>/lib/tcl8.6
> - rename the parray function, add another parameter to it
> and replace the line 'puts stdout ...' with '$t insert ...'
>
> HTH
> Helmut

After a little introspection in the console to see how [parray works]:

catch {parray ;# command is only autoloaded on demand}
# You could build the arglist here programatically, but if it's ever changed to be different, the [string map] will likely be out of date too anyway
proc tarray {a textWidget {pattern *}} [string map [list "puts stdout" "\$textWidget insert end {\n} {} "] [info body parray]]

array set myArray [list foo bar baz boing]

parray myArray
tarray myArray $textWidget

Re: I can't parray in a text widget

<ygatu2xx4cj.fsf@akutech.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralf...@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: I can't parray in a text widget
Date: Thu, 17 Nov 2022 11:28:12 +0100
Lines: 26
Message-ID: <ygatu2xx4cj.fsf@akutech.de>
References: <20221116114256.2b66ac12@lud1.home>
<tiv9nht9r2jhl4b058213o25ih6qqe4hhk@4ax.com>
<20221116125430.13a1188d@lud1.home> <tl3380$2cvgb$1@dont-email.me>
<20221116141644.7442bee3@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net /rgA3dj2RrfTxQU5MEjP1gQbUut6xdhjfw/EaenQzdrSFVdp0=
Cancel-Lock: sha1:5g1jg6oD7FSINK0HCnOCtQoQ+TA= sha1:UpzdyTH+CcsIUJXw8BIKFSFmTfs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 17 Nov 2022 10:28 UTC

* Luc <no@no.no>
| proc p.fileinfo {argNumber argInfo} {
| if {$argInfo == "all"} {

NB. Using 'eq' instead of '==' saves some CPU cycles when TCL is trying
a numerical comparison first with "==".

| return "[set ::files_[set argNumber](name) \
| [set ::files_[set argNumber](size) \
| [set ::files_[set argNumber](datetime) \
| [set ::files_[set argNumber](type) \
| [set ::files_[set argNumber](permission)"
| }
| return "[set ::files_[set argNumber]($argInfo)]"
| }

If you will ever use this function for other purposes than printing the
result, like in

lassign [p.fileinfo foo all] name size datetime type permission

I would strongly suggest to use [list] to build the return value
in the 'all' case. Otherwise it's a data-dependent bug waiting to
happen if some array(name) or any other field contains spaces.

R'

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor