1SNOBOL4TCL(1) General Commands Manual SNOBOL4TCL(1)
2
3
4
6 snobol4tcl - SNOBOL4 Tcl/Tk interface
7
8
10 -INCLUDE 'stcl.sno'
11
12 tclhandle = STCL_CREATEINTERP()
13
14 STCL_DELETEINTERP(tclhandle)
15
16 STCL_EVALFILE(tclhandle,tclfilename)
17
18 value = STCL_GETVAR(tclhandle,varname)
19
20 STCL_SETVAR(tclhandle,varname,value)
21
22 STCL_EVAL(tclhandle,tclstmt)
23
24
26 Tcl is an embedable scripting language developed by John Osterhout,
27 while at the University of Clifornia, Berkeley. Tk is a graphical user
28 interface toolkit developed for Tcl.
29
30
31 This page describes STCL, an experimental facility for invoking Tcl and
32 Tk from SNOBOL4 programs, inspired by Arjen Markus' "ftcl" FORTRAN/Tcl
33 interface
34
35
36 STCL_CREATEINTERP creates a Tcl interpreter and returns a handle which
37 can be passed to the remaining functions.
38
39
40 STCL_DELETEINTERP destroys a Tcl interpreter.
41
42
43 STCL_EVALFILE reads a Tcl script file into the referenced Tcl inter‐
44 preter.
45
46
47 STCL_GETVAR retrieves the string value of named variable from a Tcl
48 interpreter. STCL_GETVAR stores a string value of named variable in a
49 Tcl interpreter.
50
51
52 STCL_EVAL evaluates a string containing Tcl code in a Tcl interpreter.
53
55 NDBM, GDBM, and SDBM create two files: filename.dir, filename.pag.
56 Berkeley DB creates a single filename.db file.
57
58
60 -INCLUDE 'stcl.sno'
61 INTERP = STCL_CREATEINTERP()
62 TCL_VERSION = STCL_GETVAR(INTERP, "tcl_version")
63 OUTPUT = IDENT(TCL_VERSION) "Could not get tcl_version" :S(END)
64 OUTPUT = "Tcl Version: " TCL_VERSION
65
66 * check Tcl version
67 NUM = SPAN('0123456789')
68 VPAT = NUM '.' NUM
69 TCL_VERSION VPAT . VER :S(CHECKV)
70 OUTPUT = "could not parse tcl_version" :(END)
71
72 CHECKV LT(VER, 8.4) :S(CHECKTK)
73
74 * Tcl 8.4 and later can dynamicly load Tk!
75 STCL_EVAL(INTERP, "package require Tk") :F(END)
76
77 * Check for Tk
78 CHECKTK TK_VERSION = STCL_GETVAR(INTERP, "tk_version") :F(NOTK)
79 DIFFER(TK_VERSION) :S(HAVETK)
80
81 NOTK OUTPUT = "Could not find tk_version" :(END)
82
83 STCL_EVAL(INTERP, "package require Tk") :F(END)
84
85 * Check for Tk
86
87 CHECKTK TK_VERSION = STCL_GETVAR(INTERP, "tk_version") :F(NOTK)
88 DIFFER(TK_VERSION) :S(HAVETK)
89
90 NOTK OUTPUT = "Could not find tk_version" :(END)
91
92 HAVETK OUTPUT = "Tk version: " TK_VERSION
93 SEP = ';'
94
95 STCL_EVAL(INTERP,
96 + 'button .hello -text "Hello, world" -command {set foo 1}' SEP
97 + "pack .hello" SEP
98 + 'button .other -text "Other Choice" -command {set foo 2}' SEP
99 + "pack .other" SEP
100 + "global foo" SEP
101 + "vwait foo")
102
103 OUTPUT = STCL_GETVAR(INTERP, "foo")
104 END
105
106
108 tclsh(n), Tcl(n).
109
110
112 Philip L. Budne
113
114
116 NOTE! By default the STCL extension is not built into snobol4(1), it
117 must be explicitly included at build time. In Tcl 8.4 and later, Tk
118 can be dynamicly loaded by Tcl at runtime, but in earlier releases, it
119 has to be included at compile time. When dynamicly linked libraries
120 are not available, this can cause the SNOBOL4 interpreter executable to
121 expand by up to four fold! STCL should be a dynamicly loaded SNOBOL4
122 extension.
123
124
125
126
127Local 6 Dec 2005 SNOBOL4TCL(1)