Skip to content

Instantly share code, notes, and snippets.

@hkoba
Created March 24, 2013 14:56
Show Gist options
  • Save hkoba/5232253 to your computer and use it in GitHub Desktop.
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.
#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