1SNOBOL4STCL(3) CSNOBOL4 Manual SNOBOL4STCL(3)
2
3
4
6 snobol4tcl - SNOBOL4 Tcl/Tk interface
7
9 -INCLUDE 'stcl.sno'
10
12 Tcl is an embedable scripting language developed by John Osterhout,
13 while at the University of California, Berkeley. Tk is a graphical
14 user interface toolkit developed for Tcl.
15
16 This page describes a facility for invoking Tcl and Tk from SNOBOL4
17 programs, inspired by Arjen Markus' "ftcl" FORTRAN/Tcl interface
18
19 tclhandle = STCL_CREATEINTERP()
20 creates a Tcl interpreter and returns a handle which can be passed
21 to the remaining functions.
22
23 STCL_EVALFILE(tclhandle,filename)
24 reads a Tcl script file into the referenced Tcl interpreter.
25
26 STCL_GETVAR(tclhandle,varname)
27 retrieves the string value of named variable from a Tcl
28 interpreter.
29
30 STCL_SETVAR(tclhandle,varname,value)
31 sets the string value of named variable in a Tcl interpreter.
32
33 STCL_EVAL(tclhandle,tclstmt)
34 evaluates a string containing Tcl code in a Tcl interpreter.
35
36 STCL_DELETEINTERP(tclhandle)
37 destroys a Tcl interpreter.
38
39 STCL_NEWSTRINGOBJ(string)
40 Creates a tcl string object, and returns a handle for it.
41
42 STCL_GETSTRINGFROMOBJ(objhandle)
43 Get string from an Object (given object handle).
44
45 STCL_APPENDTOOBJ(objhandle, string)
46 Append string to an Object returns null string, or failure
47
48 STCL_EVALOBJEX(tclhandle, objhandle, flags)
49 Evaluate (execute) an object -- saves compiled byte code. Returns
50 integer.
51
52 objhandle = STCL_GETOBJRESULT(tclhandle)
53 return a result object from an interpreter (after TCL_EVALOBJEX)
54
55 STCL_OBJSETVAR2(tclhandle, oh_name1, oh_name2, oh_value, flags)
56
57 STCL_OBJGETVAR2(tclhandle, oh_name1, oh_name2, flags)
58
59 STCL_RELEASEOBJ(objhandle)
60 release a Tcl Object
61
63 -INCLUDE 'stcl.sno'
64 INTERP = STCL_CREATEINTERP()
65 TCL_VERSION = STCL_GETVAR(INTERP, "tcl_version")
66 OUTPUT = IDENT(TCL_VERSION) "Could not get tcl_version" :S(END)
67 OUTPUT = "Tcl Version: " TCL_VERSION
68
69 # check Tcl version
70 NUM = SPAN('0123456789')
71 VPAT = NUM '.' NUM
72 TCL_VERSION VPAT . VER :S(CHECKV)
73 OUTPUT = "could not parse tcl_version" :(END)
74
75 CHECKV LT(VER, 8.4) :S(CHECKTK)
76
77 # Tcl 8.4 and later can dynamicly load Tk!
78 STCL_EVAL(INTERP, "package require Tk") :F(END)
79
80 # Check for Tk
81 CHECKTK TK_VERSION = STCL_GETVAR(INTERP, "tk_version") :F(NO_TK)
82 DIFFER(TK_VERSION) :S(HAVETK)
83 NO_TK OUTPUT = "Could not find tk_version" :(END)
84
85 HAVETK OUTPUT = "Tk version: " TK_VERSION
86
87 LOOP OUTPUT = STCL_EVAL(INTERP,
88 + 'tk_messageBox -message "Alert!"'
89 + ' -type ok -icon info')
90 VAL = STCL_EVAL(INTERP,
91 + 'tk_messageBox -message "Really quit?"'
92 + ' -type yesno -icon question')
93 OUTPUT = VAL
94 DIFFER(VAL, "yes") :S(LOOP)
95 END
96
98 tclsh(1), wish(1).
99 http://ftcl.sourceforge.net/
100
102 Philip L. Budne
103
104
105
106CSNOBOL4B 2.3.1 March 31, 2022 SNOBOL4STCL(3)