Created
March 24, 2013 14:56
-
-
Save hkoba/5232253 to your computer and use it in GitHub Desktop.
With this snippet, you can easily eval tcl script.
Note: I'm very new to OCaml. Any suggestions are welcome.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "labltk.cma";; | |
(* You must call Tk.openTk somewhere before tcl_eval *) | |
let top = Tk.openTk () | |
let rec tcl_eval_str str = | |
tcl_eval_list (Protocol.splitlist str) | |
and tcl_eval_list lst = | |
Protocol.tkEval (list2tkArgs lst) | |
and list2tkArgs lst = | |
Array.of_list (List.map (fun i -> Protocol.TkToken i) lst) | |
;; | |
(* Example: *) | |
print_endline (tcl_eval_str "glob *"); | |
print_endline (tcl_eval_list ["lsort"; "-decreasing"; "foo bar baz"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment