version0.7.10
This commit is contained in:
parent
4d4b3b1c04
commit
36818817bd
14 changed files with 1011 additions and 0 deletions
25
examples/tclex.nim
Normal file
25
examples/tclex.nim
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Example to embed TCL in Nimrod
|
||||
|
||||
import tcl, os
|
||||
|
||||
const
|
||||
myScript = """puts "Hello, World - In quotes" """
|
||||
myScript2 = """
|
||||
package require Tk
|
||||
pack [entry .e -textvar e -width 50]
|
||||
bind .e <Return> {
|
||||
set e [regsub { *=.*} $e ""] ;# remove evaluation (Chris)
|
||||
catch {expr [string map {/ *1./} $e]} res
|
||||
append e " = $res"
|
||||
}
|
||||
"""
|
||||
|
||||
Tcl_FindExecutable(getApplicationFilename())
|
||||
var interp = Tcl_CreateInterp()
|
||||
if interp == nil: quit("cannot create TCL interpreter")
|
||||
if Tcl_Init(interp) != TCL_OK:
|
||||
quit("cannot init interpreter")
|
||||
if Tcl_Eval(interp, myScript) != TCL_OK:
|
||||
quit("cannot execute script.tcl")
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue