Re: Help for a beginner

Juergen Schoenwaelder (schoenw@bayes)
Mon, 29 Nov 93 14:08:24 +0100

Hi!

Nenad> I am trying to adapt tkined to a specific task that I have
Nenad> involving drawing and editing tabular forms of entities and,
Nenad> than, drawing a network based on the definiton of these
Nenad> entities.

Nenad> My problem is that I am not sure how to go about adapting
Nenad> tkined for my purposes. What I would like to do is simply
Nenad> build on top of tkined functionality writing tk/tcl scripts.
Nenad> However, I am not sure what is the way to do this (i.e., where
Nenad> and when do you read in a regular tk/tcl script to tkined).
Nenad> The answer must be so obvious that it hasn't been spelled out
Nenad> anywhere I could read it from.

We never read in any tk/tcl scripts to tkined directly. Every script
that controls icons etc. shown inside of the editor communicates with
tkined using a socketpair. This allows us to hide the internals of
tkined and has the big advantage, that tkined never fails because of a
buggy script.

Communication between tkined and a tcl script is hidden by the ined
proc that is defined in ined.tcl. To write your own script, you have
to source ined.tcl or you can use the -i option if you are using
scotty. Thereafter you are able to use all the ined commands described
in the tkined man page.

Below is a simple hello world example. The script defines a proc hello
that will be called whenever the user selects the hello menu item.
The argument, a list of all selected objects, is simply ignored. The
second proc delete Hello Example deletes the tool and exits the
script.

The last line in the script tells tkined to create a new menu named
TOOL that contains the commands hello, a separator and delete Hello
Example.

You can start the example below (assuming it is stored in hello.tcl)
using the Start Interpreter menu of the TOOL Manager or you can define

tkined.interpreter2: hello.tcl

in your ~/.tkined/tkined.defaults. This tells tkined to start
hello.tcl whenever a new editor window is opened. You must make sure
that tkined can find hello.tcl. The easiest way is to put hello.tcl in
your ~/.tkined directory.

I hope this short note helps you to do your first steps writing tcl
scripts for tkined.

Juergen

----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<----

#! /usr/local/bin/scotty -inf
##
## A hello world example written for tkined.
##

##
## A new tkined command that simply displays the message `Hello World!'.
##

proc hello {list} {
ined acknowledge "Hello World!"
}

##
## Delete this TOOL
##

proc "delete Hello Example" {list} {
global tools
foreach id $tools { ined delete $id }
exit
}

set tools [ ined create TOOL "Hello Example" hello "" "delete Hello Example" ]