SNOBOL4STCL(3)
β¨ SNOBOL4STCL β the CSNOBOL4 manual, bestie edition β¨
okay so likeβ¦ this page lives in the CSNOBOL4 manual, and it's all about snobol4tcl, aka the SNOBOL4 Tcl/Tk interface. yes we're calling Tcl and Tk from SNOBOL4. it's giving time travel, it's giving crossover episode, and honestly? iconic. π
πΈ NAME πΈ
snobol4tcl β the SNOBOL4 Tcl/Tk interface. that's it, that's the whole name, slay. π
π¦ SYNOPSIS π¦
-INCLUDE 'stcl.sno'
literally just that one line, no cap. include the file and you're in. π
β¨ DESCRIPTION β¨
okay so first, lore. Tcl is an embeddable scripting language, and it was developed by John Osterhout, while he was at the University of California, Berkeley. and Tk? that's the graphical user interface toolkit that was developed for Tcl. dynamic duo fr fr. π«Ά
this page is describing a facility for invoking Tcl and Tk from SNOBOL4 programs, and it was inspired by Arjen Markus' "ftcl" FORTRAN/Tcl interface. cute lineage, we love to see it. π
here's the whole roster, bestie, every single one, no skipping:
tclhandle = STCL_CREATEINTERP()β creates a Tcl interpreter and hands you back a handle. that handle is the golden ticket ποΈ you pass to all the remaining functions.STCL_EVALFILE(tclhandle,filename)β reads a Tcl script file into the referenced Tcl interpreter.STCL_GETVAR(tclhandle,varname)β retrieves the string value of the named variable from a Tcl interpreter.STCL_SETVAR(tclhandle,varname,value)β sets the string value of the named variable in a Tcl interpreter.STCL_EVAL(tclhandle,tclstmt)β evaluates a string containing Tcl code in a Tcl interpreter.STCL_DELETEINTERP(tclhandle)β destroys a Tcl interpreter. bye bestie π (this is the cleanup step, don't ghost it).STCL_NEWSTRINGOBJ(string)β creates a tcl string object, and returns a handle for it.STCL_GETSTRINGFROMOBJ(objhandle)β gets the string from an Object (you hand it the object handle).STCL_APPENDTOOBJ(objhandle, string)β appends a string to an Object, and returns a null string, or failure. πSTCL_EVALOBJEX(tclhandle, objhandle, flags)β evaluates (executes) an object, and it saves compiled byte code. returns an integer.objhandle = STCL_GETOBJRESULT(tclhandle)β returns a result object from an interpreter (do this afterTCL_EVALOBJEX).STCL_OBJSETVAR2(tclhandle, oh_name1, oh_name2, oh_value, flags)β that's the signature, bestie, straight up.STCL_OBJGETVAR2(tclhandle, oh_name1, oh_name2, flags)β and this one too.STCL_RELEASEOBJ(objhandle)β releases a Tcl Object. let it go, let it goooo π§
π EXAMPLE π
here's a whole little program that checks your Tcl version, checks your Tk version, and then bullies you with popups until you say yes. main character energy tbh. π
-INCLUDE 'stcl.sno'
INTERP = STCL_CREATEINTERP()
TCL_VERSION = STCL_GETVAR(INTERP, "tcl_version")
OUTPUT = IDENT(TCL_VERSION) "Could not get tcl_version" :S(END)
OUTPUT = "Tcl Version: " TCL_VERSION
# check Tcl version
NUM = SPAN('0123456789')
VPAT = NUM '.' NUM
TCL_VERSION VPAT . VER :S(CHECKV)
OUTPUT = "could not parse tcl_version" :(END)
CHECKV LT(VER, 8.4) :S(CHECKTK)
# Tcl 8.4 and later can dynamicly load Tk!
STCL_EVAL(INTERP, "package require Tk") :F(END)
# Check for Tk
CHECKTK TK_VERSION = STCL_GETVAR(INTERP, "tk_version") :F(NO_TK)
DIFFER(TK_VERSION) :S(HAVETK)
NO_TK OUTPUT = "Could not find tk_version" :(END)
HAVETK OUTPUT = "Tk version: " TK_VERSION
LOOP OUTPUT = STCL_EVAL(INTERP,
+ 'tk_messageBox -message "Alert!"'
+ ' -type ok -icon info')
VAL = STCL_EVAL(INTERP,
+ 'tk_messageBox -message "Really quit?"'
+ ' -type yesno -icon question')
OUTPUT = VAL
DIFFER(VAL, "yes") :S(LOOP)
END
not the LOOP going until you type yesβ¦ the program said "we're not done here" and meant it. π
π₯ SEE ALSO π₯
go read those too, iykyk. π«
π AUTHOR π
Philip L. Budne β thank you for your service, king. π«‘π
and that's the whole page, bestie!! this was the SNOBOL4STCL(3) page from the CSNOBOL4B 2.3.1 manual, dated March 31, 2022. go forth and STCL_CREATEINTERP() responsibly. periodt. π
β¨πΈ
π¦ where this page comes from
- fedora 43: snobol4 2.3.1-7.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND ISC
- fedora 44: snobol4 2.3.1-8.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND ISC
- opensuse-leap 16.0: snobol4 2.3.1-160000.2.2 Β· BSD-2-Clause
- opensuse-leap 16.0: snobol4 2.3.1-160000.2.2 Β· BSD-2-Clause
- opensuse-leap 16.0: snobol4 2.3.1-160000.2.2 Β· BSD-2-Clause
- opensuse-leap 16.0: snobol4 2.3.1-160000.2.2 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms