1998-01-16 07:19:09 -05:00
|
|
|
#! /usr/local/bin/ruby -vd
|
2015-12-16 00:31:54 -05:00
|
|
|
# frozen_string_literal: false
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# tcltklib ライブラリのテスト
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
require "tcltklib"
|
|
|
|
|
|
|
|
def test
|
2011-09-14 13:25:37 -04:00
|
|
|
# インタプリタを生成する
|
1998-01-16 07:19:09 -05:00
|
|
|
ip1 = TclTkIp.new()
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# 評価してみる
|
1998-01-16 07:19:09 -05:00
|
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
print ip1._eval("puts {abc}").inspect, "\n"
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# ボタンを作ってみる
|
1998-01-16 07:19:09 -05:00
|
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
print ip1._eval("button .lab -text exit -command \"destroy .\"").inspect,
|
|
|
|
"\n"
|
|
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
print ip1._eval("pack .lab").inspect, "\n"
|
|
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# インタプリタから ruby コマンドを評価してみる
|
1998-01-16 07:19:09 -05:00
|
|
|
# print ip1._eval(%q/ruby {print "print by ruby\n"}/).inspect, "\n"
|
|
|
|
print ip1._eval(%q+puts [ruby {print "print by ruby\n"; "puts by tcl/tk"}]+).inspect, "\n"
|
|
|
|
print ip1._return_value().inspect, "\n"
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# もう一つインタプリタを生成してみる
|
1998-01-16 07:19:09 -05:00
|
|
|
ip2 = TclTkIp.new()
|
|
|
|
ip2._eval("button .lab -text test -command \"puts test ; destroy .\"")
|
|
|
|
ip2._eval("pack .lab")
|
|
|
|
|
|
|
|
TclTkLib.mainloop
|
|
|
|
end
|
|
|
|
|
|
|
|
test
|
|
|
|
GC.start
|
|
|
|
|
|
|
|
print "exit\n"
|