HDTenEightyP/NetNews huggingface dataset:
From: ouster@sprite.Berkeley.EDU (John Ousterhout)
Newsgroups: comp.lang.tcl
Subject: Re: How do I imbed tcl in an application
Date: 29 Jul 1992 16:15:24 GMT
Organization: U.C. Berkeley Sprite Project
Distribution: world
NNTP-Posting-Host: tyranny.berkeley.edu

A couple of comments on this.

First, in response to Kevin Kenny's question about the noun-versus-verb
approach to Tcl commands:

    John Ousterhout has experimented with both methods: files in Tcl are
    identified by handles, while widgets in Tk are independent commands
    having client data.  John, do you have anything to add about the
    tradeoffs?

I don't have much to add to this.  To tell the truth, I never thought
very explicitly about this choice until seeing it in Kevin's message.
I used the handle approach for files because that seemed a natural
imitation of the corresponding UNIX C procedures, and I used the
"object-name-as-command" approach for Tk widgets because that provided
for a uniform approach across all widget types and allowed inidividual
widget types to define different sets of sub-commands without polluting
the Tcl command space.  In retrospect, I think I like the "object-name-as
command" approach better, but I think it works best for moderate numbers
of objects (10's or 100's).  If there are a million objects, then I think
the handle approach would have significantly lower overhead.

Second, Larry Virden asked about the extension at the level of sub-commands:

    Something that I have been wondering about along these lines is based on
    John's two initial papers.  They described the tcl/tk environment in 
    such a way that it seemed that a user would be able to write their own
    extended sub-options for tcl commands and then the application would
    read these extentions / parameters , etc and allow the user customizations.
    
    Did I get the wrong idea?  Is there a way for me to add new commands to
    a tcl/tk application automatically, or does each application need to add
    code to handle this possibility?  If so, where does that fit into the
    previously described skeleton that you folks are talking about?

You can add commands, but you can't add subcommands to existing commands.
For example, if you wanted to add a "remove" option to the string command,
so that you could say "string remove <string> <letter>" to remove all
instances of <letter> from <string>, you'd have to modify the C code that
implements "string".
From: gaede@bearsan.sda.COM (Steve Gaede)
Newsgroups: comp.lang.tcl
Subject: tkText help?
Keywords: interaction with scrollbars
Date: 22 Jul 92 21:23:29 GMT
Organization: Software Design & Analysis Inc., Boulder, CO

Can anyone help me with this one?

I've installed the tkText widget 2.0 in TK 2.1. I'm using xf to 
configure a GUI with text editing widget and scrollbars.  I source the
code that xf generates, and then do the work I want to do to
fill the text widget, etc.

I populate the widget by doing an insert at 0 with the contents of a file.
(This particular file has 7 lines). When I do so, the text widget executes 
its "yscrollcommand" with invalid arguments (note that lastUnit is greater 
than firstUnit):

    illegal lastUnit 6
	while executing
	".frame.scrollbar1 set 7 0 7 6"

I get this error message only once, and after that scrolling works just
fine.

Any ideas for why this is happening, and how to fix it?

Steve Gaede
gaede@sda.com
Newsgroups: comp.lang.tcl
From: schwartz@roke.cs.psu.edu (Scott Schwartz)
Subject: Re: Installing TCL/TK so it can be used for development
	<1992Jul23.124705.21577@NeoSoft.com>
Date: Thu, 23 Jul 1992 21:45:06 GMT


As long as we're comparing installation details, I've put tcl stuff in
	/depot/tcl/{bin,include,lib,library,man}

I put the tk scripts in with the tcl ones, mostly since mxedit seemed
to want it that way.  Right now it seems like an acceptable choice,
although I could see splitting them up if they grow in number by an
appreciable amount.

One problem with standard tcl is that TCL_LIBRARY is compiled in, so
[info library] will be wrong if you move things around.  Tclx does
better, since things are set in a defaults file which you can
override.
Newsgroups: comp.lang.tcl
From: rjb1@gte.com (Richard J. Brandau)
Newsgroups: comp.lang.tcl
Subject: tk widgets from Motif libs?
Date: 28 Jul 92 20:46:24 GMT
Organization: GTE Laboratories Incorporated, Waltham MA

Have tk widgets ever been built from the Motif libraries?  If not,
what would be involved in doing this?

-- Rich Brandau, GTE Labs
Newsgroups: comp.lang.tcl
From: gwlester@cpu.com (Gerald W. Lester)
Subject: Re: How do I imbed tcl in an application
Organization: Computerized Processes Unlimited, Metairie, LA, (504)-889-2784
Date: Fri, 31 Jul 1992 13:25:12 GMT
Reply-To: gwlester@cpu.com

In article <ADRIANHO.92Jul30145641@barkley.berkeley.edu>, adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
>>   Another change that would be noce is to extend the proc command to take
>>an optional fourth arguement that would be a tcl command to invoke when the
>>procedure is deleted.
>
>Adding that just requires a few changes to Tcl_ProcCmd() to accomplish
>that, but I can't think of any application for this enhancement.  Can
>you suggest any concrete examples?  (The reason I ask is coz I figured
>John would've added it a long time ago if it had any utility.)

Adrian,

	Sure, I'm writting a server.  I have a procedure in my program, that
*must* not be changed (like something that checks security).  I would like to
put a delete command on that causes a failure if, on of the files that get
sourced in to handle a service request, an attempt is made to redefine the 
procedure in question.

	If one is using Extended Tcl with packages (*.tlib) the problem becomes
even more likely unless your packages are very small.
From: kennykb@dssv01.crd.ge.com (Kevin B. Kenny)
Newsgroups: comp.lang.tcl
Subject: Re: How do I imbed tcl in an application
Date: 28 Jul 92 17:27:14 GMT
Reply-To: kennykb@crd.ge.com
Organization: GE R&D, Information Architectures & Management Program


In article <1992Jul28.114518.12123@rchland.ibm.com> you write:
|> Question 2: (long winded, sorry)
|> 
|> How do I provide access to structures more complex than just strings?
|> 
|> For example, I've got a structure 
|> 
|> typedef struct {
|>     char *name;
|>     int  rank;
|>     int  ssn;
|> } Soldier;
|> 
|> Soldier grunt;
|> 
|> Now, is there any way I can pass ``grunt'' to a tcl proc and have it be
|> able to access grunt.name or grunt.rank ?

My preference is to have a single Tcl function that represents an
object.  For instance, in the tclTCP package, there is a command,

	tcp server

that creates a TCP server object.  One of the side effects to `tcp
server' is that it creates a new Tcl command, with a name like
`tcp_server_4', and returns its name.  The data structure describing
the server is allocated from free store and initialized, and carried
along as the command's client data.  That way, I can say

	set s [tcp server]

and then say things like

	# Begin accepting connections
	$s start
	# Tell the user what port we're listening to
	puts stdout "Server is listening at [$s configure -port]"

... and so on.  If you want to see some more coding examples, ftp the
tclTCP package from barkley.berkeley.edu.

Extended Tcl uses a competing approach, owing primarily to personal
taste (Karl Lehenbauer doesn't care for the noun-verb syntax that the
use of the client data enforces, while I prefer it).  It has an
additional type of object called a `handle' that provides a textual
reference to the data structures.  If you ftp Extended Tcl from
barkley.berkeley.edu, you'll find a file called `Handle.man' in the
`man' directory that describes the C rountines that Extended Tcl uses
to map between structure pointers and textual names.

If I had done tclTCP the latter way, the syntax would have looked
like:

	set s [tcp create_server]
	# Start accepting new connections
	server start $s
	# Tell the user the listening port
	puts stdout "Server listening at port [server configure $s -port]"

... and so on.  The code would also have been a trifle more
complicated, because the handles would have to be converted to
pointers explicitly, rather than having Tcl_Eval just look up a client
data word.  As I said, which method to choose is largely a matter of
personal taste.

John Ousterhout has experimented with both methods: files in Tcl are
identified by handles, while widgets in Tk are independent commands
having client data.  John, do you have anything to add about the
tradeoffs?  

73 de ke9tv/2, Kevin          There isn't any .signature virus, is there?
From: gwlester@cpu.com (Gerald W. Lester)
Newsgroups: comp.lang.tcl
Subject: Re: How do I imbed tcl in an application
Date: 30 Jul 92 13:03:52 GMT
Article-I.D.: cpu.1992Jul30.130352.11885
Reply-To: gwlester@cpu.com
Organization: Computerized Processes Unlimited, Metairie, LA, (504)-889-2784

In article <ADRIANHO.92Jul29201730@barkley.berkeley.edu>, adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
>
>IMHO, a neater way is to modify the Tcl library to allow for the
>specification and storage of subcommand descriptors.  Properly done, a
>Tcl programmer would be able to create a theoretically infinite tree
>of subcommands without changing the programming interface a single
>bit, like this:
>

Adrian,

	I agree, your proposed change would be nice, but the poster wanted to
be able to extend a command from *Tcl*  your suggestion only directly allows it
to be done from *C*.

	Another change that would be noce is to extend the proc command to take
an optional fourth arguement that would be a tcl command to invoke when the
procedure is deleted.
From: rtor@ansa.co.uk (Owen Rees)
Newsgroups: comp.lang.tcl
Subject: Re: bug in expr?
Date: 22 Jul 92 10:15:22 GMT


(Kevin B. Kenny) writes:

> Can someone explain the following?  More to the point, can someone fix it?
> 
> wish: set x [expr 400000.0+500000.0]
> 900000
> wish: set y [expr $x*$x]
> -1748818944
> 
> The square of 900000.0 oughtn't to be a large negative number.

The square of 900000.0 isn't a large negative number e.g.:

wish: set x 900000.0
900000.0
wish: set y [expr $x*$x]
8.1e+11

The problem is that you are squaring "900000" and not "900000.0" -
don't forget that "Tcl supports only one type of data: strings." and
that expr returns the result as a string. The 'insignificant' zeros
and the decimal point have been stripped off because %g is used to
convert the result to a string.

One thing you could do is use format to force the string to have its
decimal point as in:

wish: set x [format "%#g" [expr 400000.0+500000.0]]
900000.
wish: set y [expr $x*$x]
8.1e+11

or you could force the second expr to use floating point like this:

wish: set x [expr 400000.0+500000.0]
900000
wish: set y [expr 1.0*$x*$x]
8.1e+11


Owen.

     /\/\	Owen Rees <rtor@ansa.co.uk>
    / /  \	APM, Poseidon House
   / / /\ \	Castle Park, Cambridge
  / / /\ \ \	CB3 0RD, UK
 / /_/__\ \ \	Phone:	+ 44 223 323010
/__________\_\	Fax:	+ 44 223 359779
  A  N  S  A
From: csd05@seq1.keele.ac.uk (Yufan Hu)
Newsgroups: comp.lang.tcl
Subject: Ring bell?
Date: 21 Jul 92 12:02:01 GMT
Organization: University of Keele, England
X-Newsreader: Tin 1.1 PL4


Hi there,

Can somebody tell me how to ring a bell on the server from a tk script?

Thank you very much for the help.

-Yufan
==============================================================================
JANET : yufan@uk.ac.keele.cs     || Yufan Hu
BITNET: yufan%cs.kl.ac.uk@ukacrl || Dept. of Computer Science, Univ. of Keele,
other : yufan@cs.keele.ac.uk     || Keele, Staffordshire.  ST5 5BG.  U.K.
------------------------------------------------------------------------------
Telephone: +44-782-621111 x 7357    FAX:  +44-782-713082
==============================================================================
Newsgroups: comp.lang.tcl
From: peter@taronga.com (Peter da Silva)
Subject: Re: How do I imbed tcl in an application
Organization: Taronga Park BBS
Date: Thu, 30 Jul 1992 11:14:50 GMT

In article <ADRIANHO.92Jul29201730@barkley.berkeley.edu> adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
>Tcl_CreateCommand(interp, "string remove", Tcl_StringRemoveCmd,
>		  clientData, deleteProc);

Why restrict it to "Tcl_CreateCommand"?

proc {string remove} {string substring} {
	...
}
-- 
                                                                `-_-'
                         Have you hugged your wolf today?        'U`

Peter da Silva, Taronga Park BBS, Houston, TX  +1 713 568 0480/1032
From: adrianho@barkley.berkeley.edu (Adrian J Ho)
Newsgroups: comp.lang.tcl
Subject: Re: How do I imbed tcl in an application
Date: 30 Jul 92 14:50:22
Organization: University of California, Berkeley
	<ADRIANHO.92Jul29201730@barkley.berkeley.edu> <GMUHCO3@taronga.com>
NNTP-Posting-Host: barkley.berkeley.edu
In-reply-to: peter@taronga.com's message of 30 Jul 92 11:14:50 GMT

In article <GMUHCO3@taronga.com> peter@taronga.com (Peter da Silva) writes:
>In article <ADRIANHO.92Jul29201730@barkley.berkeley.edu> adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
>>Tcl_CreateCommand(interp, "string remove", Tcl_StringRemoveCmd,
>>		  clientData, deleteProc);
>Why restrict it to "Tcl_CreateCommand"?
>proc {string remove} {string substring} {
>	   ...
>}

Well, if I read the Tcl sources correctly, Tcl_ProcCmd() (the routine
that processes the "proc" command) calls Tcl_CreateCommand with
argv[1] as the command name.  So, I think that takes care of the Tcl
case too.
--
-----------------------------------------------------------------------------
Adrian Ho, He With The Embarrassingly *Dead* Passion ** Phone: (510) 642-5563
System Manager, CFD Lab, ME Dept, UC Berkeley * adrianho@barkley.berkeley.edu
Maintainer, Tcl/Tk Contrib Archive ---- barkley.berkeley.edu [128.32.142.237]
  Send all Tcl/Tk Archive-related stuff to tcl-archive@barkley.berkeley.edu
Newsgroups: comp.lang.tcl
From: mmoore%peruvian.utah.edu@cs.utah.edu (Michael Moore)
Subject: Application Default Files
Date: 30 Jul 92 22:14:20 MDT
Organization: University of Utah CS Dept., Salt Lake City
Distribution: usa


	I'm sorry to bother everyone with this trivial question,
but what is the classname used by wish for its main shell window?
The reason I want to know is because I want to set up application
defaults files here on our system but I can't seem to figure out
what the name of the file should be.... 

	I can easily set resources within my own .Xdefaults file,
but what is needed is the backup resources for those who have not
done this.

	Since all the tk scripts are run through wish, it occurs
to me that perhaps all programs have the same application class
name (as set by wish) unless the script performs some command to
forcibly change it... or is this wrong?

	Please help me clear this up....


	-Thanks,

	Michael Moore

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Michael D. Moore     Office : (801) 582-5847x4721  Home : (801)359-6552  +
+Software Q&A Programmer   Evans & Sutherland     mmoore@dsd.es.com       +
+Student                   University of Utah     mmoore@peruvian.utah.edu+
Newsgroups: comp.lang.tcl
From: johng@cimage.com (John Gourlay)
Subject: Re: Tcl in Microsoft Windows
Organization: Cimage Corp, Ann Arbor, MI
X-Newsreader: Tin 1.1 PL4
Date: Tue, 28 Jul 92 14:44:08 GMT

Thanks.  I got my acknowledgement.

John Gourlay
johng@cimage.com
Newsgroups: comp.lang.tcl
From: cgp@Arco.COM (Chris Phillips  (214) 754-6419)
Newsgroups: comp.lang.tcl
Subject: uplevel/upvar and trace
Date: 22 Jul 92 20:34:40 GMT
Article-I.D.: Arco.1992Jul22.203440.15926
Distribution: usa
Organization: ARCO Oil and Gas Company

Apparently there is no difference in

	proc s1 {n i op} {
		set z [uplevel set [set n]]
		puts stdout $z
	}
and
	proc s2 {n i op} {
		upvar $n z
		puts stdout $z
	}

For example,

tcl>trace var a w s1
tcl>set a 5
5
tcl>trace vdel a w s1
tcl>trace var a w s2
tcl>set a 5
5
tcl>

However, the following extensions to arrays doesn't work
for the upvar version:

	proc a1 {n i op} {
		set z [uplevel set [set n]($i)]
		puts stdout $z
	}
	proc a2 {n i op} {
		upvar [set n]($i) z
		puts stdout $z
	}

tcl>trace var b(1) w a1   
tcl>set b(1) 2
2
tcl>trace vdel b(1) w a1
tcl>trace var b(1) w a2
tcl>set b(1) 2
Error: can't set "b(1)": access disallowed by trace command
tcl>

Why?

Chris
Newsgroups: comp.lang.tcl
From: shmdgljd@rchland.vnet.ibm.com (Jay Schmidgall)
Subject: Re: How do I imbed tcl in an application
Date: Tue, 28 Jul 1992 11:45:18 GMT
Reply-To: jay@vnet.ibm.com
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
Organization: IBM Rochester, MN

In article <ADRIANHO.92Jul27175403@barkley.berkeley.edu>, adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
|> A pretty good example is in the Tcl distribution itself: tclTest.c is
|> a simple Tcl command-shell.

Thanks to Adrian and the off-line responses.  The consensus seems to be look
at how tclTest works, which I am in the process of doing.

Question 2: (long winded, sorry)

How do I provide access to structures more complex than just strings?

For example, I've got a structure 

typedef struct {
    char *name;
    int  rank;
    int  ssn;
} Soldier;

Soldier grunt;

Now, is there any way I can pass ``grunt'' to a tcl proc and have it be
able to access grunt.name or grunt.rank ?

I was thinking that I would do this by adding a new command, say soldier,
which would be like

    soldier name x : returns x.name
    soldier rank x : returns x.rank
    soldier ssn x  : returns x.ssn

But I'm still left with the problem of x being a Soldier, rather than a
string.  For that matter, how would I initialize x.name?

Hmmm.  I guess what I'm wondering is sort of how other people have made
the association between a string and the more complex data structure of
which that string is just the name? a pointer to it, somehow? ??

I hope this makes sense.

(In the meantime, I'll look at tk as well to see how the man did it for
 windows, etc.)
-- 
: jay          jay@vnet.ibm.com    My opinions and ideas, not my employer's.
: shmdgljd@rchland.vnet.ibm.com    (c) Copyright 1992.  All rights reserved.
Newsgroups: comp.lang.tcl
From: rick@IMD.Sterling.COM (Richard Ohnemus)
Subject: Re: BEEP?
Organization: Sterling Software, IMD
Date: Mon, 27 Jul 1992 22:26:11 GMT
X-Md4-Signature: 2c20a8ca8e4e5e4053ddca1ea0f95c87

In article <1992Jul27.142547.13410@cpu.com> gwlester@cpu.com writes:
>In article <681@ceylon.gte.com>, mw06@newshost.gte.com (Mark Weissman) writes:
>>Is there any way in tk/wish to make the display showing the 
>>tk windows beep?
>
>No,
>
>	It is a easy addition, I'm sending John my patch.  if you are
>interested send me e-mail and I'll either post the patch or mail it to you.
>


Back around the end of May I posted a set of patches to tk to provide
'beep' and 'cutbuffer' commands (manual pages are included for both
commands). I can e-mail it to any one that missed it.

I can't remember if I sent it to John for possible inclusion in the
next release.
-- 
Rick Ohnemus   INTERNET: rick@IMD.Sterling.COM   UUCP: uunet!sparky!rick
LAND: Sterling Software IMD, 1404 Ft. Crook Rd. South, Bellevue NE. 68005-2969
Phone: (402) 291-8300        FAX: (402) 291-4362
I never receive credit for anything I write! (I'm an Ohnemus. 8-)
From: gah@grenache (George A. Howlett)
Newsgroups: comp.lang.tcl
Subject: Re: bug in expr?
Date: 22 Jul 92 16:39:13 GMT
Reply-To: george.howlett@att.com
Organization: AT&T Bell Laboratories
X-Newsreader: Tin 1.1 PL4

kennykb@dssv01.crd.ge.com (Kevin B. Kenny) writes:
: 
: Can someone explain the following?  More to the point, can someone fix it?
: 
: wish: set x [expr 400000.0+500000.0]
: 900000
: wish: set y [expr $x*$x]
: -1748818944
: 
: The square of 900000.0 oughtn't to be a large negative number.
: 
: 
: 73 de ke9tv/2, Kevin          There isn't any .signature virus, is there?

I think the point that Kevin is making is that if you started out
with floating point values, you should get a floating point result.
The implicit demotion of the sum of two floating point numbers into
a integer result is unexpected.  It's fairly easy to detect here,
but insidiously hard to track in more complex usages. 

Another problem, noted in an earlier posting by Brian Smith:
: Here's an annoying bug in tcl dealing with double precision arithmetic.
: Not really a "bug", so much, but a lousy feature.  It seems the expr
: command is intent on rounding off all double precesions values to about
: 6 significant figures, whereas 14-15 are present on most machines.  For
: example, "expr 123456.789012345" returns "123457", but the command
: "expr 123456.789012345-123456.7890123" returns "4.50091e-08", which is
: pretty reasonable.
:
: Easily fixed (chang "%g" to "%lf" in tclExpr.c), but annoying if you're
: trying to do accurate arithmetic.
:
: --
: -----
: Brian C. Smith
: bsmith@cs.Berkeley.EDU
: University of California, Berkeley
: Computer Sciences Department
: (510)642-9585


You could simply change the format in tclExpr.c.  Unfortunately, 
this still doesn't address the round-off problem and could break
existing code which relies on the implicit demotion or a compact
representation of a floating point number.

The solution I adopted has the same mechanism as "awk".  In awk, the
format of the converted floating point number is controlled by the
variable OFMT.  Setting this variable changes the format conversion.
The default format is "%g".

In Kevin's example:

wish: set OFMT %#g
%#g
wish: set x [expr 400000.0+500000.0]
900000.
wish: set y [expr $x*$x]
8.10000e+11
wish: unset OFMT
wish: set x [expr 400000.0+500000.0]
900000

This way one can set the format for the problem at hand without
breaking existing code.

I can repost this patch if anyone's interested.

BTW: If you are using the patch to add math library functions,
     you could have explicitly promoted x using the "float()"
     function.

wish: set x [expr 400000.0+500000.0]
900000
wish: set y [expr float($x)*$x]
8.1e+11

--gah
From: jiangwu@sickdog.CS.Berkeley.EDU (Jiang Wu)
Subject: NO Bugs in Canvas Rect/Oval item
Followup-To: Bugs in Canvas Rect/Oval item
Organization: University of California, Berkeley
Date: Fri, 31 Jul 1992 20:01:08 GMT


Upon receiving e-mail from John Ousterhout and Tim Mooney telling me
that they could not reproduce the bug I claimed in my last posting, I
went back to wish and did some more experiment.

There is NO bug in the Tk2.1 canvas rect/oval item.  The bug is in canvas
pixmap extension that we received from Allen Downey.  The canvas pixmap
extension is a patch the original Tk2.1 canvas rect/oval code.  I didn't
about this until today.  That is why I thought the bug was in the Tk2.1
canvas rect/oval.  I am sorry about that.

-- Jiang Wu
   jiangwu@postgres.berkeley.edu