[#4754] Now,I am starting ruby. — mamoru@... (Mamoru Matushita)

先日、初めて投稿したつもりだったのですが間違えて

14 messages 1997/10/02

[#4891] mixin - singleton method inheritance, const etc... — shugo@... (Shugo Maeda)

前田です。

13 messages 1997/10/10

[#5000] ruby 1.0-971015 released — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

14 messages 1997/10/15

[#5056] RubyでOODB — hisanori@...

松尾です。

20 messages 1997/10/20
[#5057] Re: RubyでOODB — matz@... (Yukihiro Matsumoto) 1997/10/20

まつもと ゆきひろです

[#5065] Re: RubyでOODB — hisanori@... 1997/10/20

松尾です。

[#5066] Re: RubyでOODB — matz@... (Yukihiro Matsumoto) 1997/10/20

まつもと ゆきひろです

[ruby-list:5127] Re: ruby & tk(wish)

From: tateishi@... (Tateishi Takaaki)
Date: 1997-10-23 23:07:36 UTC
List: ruby-list #5127
立石です。

>> ;; wishでの変数をrubyでそのまま文字列から扱える
>> ;; ようにできればいいなぁとか思ってます。
>> ;; たとえば
>> ;; a = "button1";
>> ;; Tk.write("button $a");
>> ;; でwishでの
>> ;; set a "button1"
>> ;; button $a
>> ;; と同等の操作ができTk.writeでwishでの戻り値が返って
>> ;; くるとか、、、、、、(^^;
>> ;; 戻り値を受け取ることってできるのでしょうか?

これをスクリプトレベルで実現させようとして次のような
簡単なスクリプトを書きましたが、なんとか戻り値を得る
ことはできないのでしょうか?
また、rubyでの大域変数をwishへ反映させることはできるのですが
その逆は可能でしょうか?

例' 	a = Wish.new
	a.init
	$button1 = ".b1"
	$button2 = ".b2"
	a.command("button $button1 -text Quit -command exit")
	a.command("button $button2 -text {do nothing}")
	a.command("pack $button1 $button2")
	......
	..do anything...
	......
	a.close

-----------------------------------------------------
# wish.rb
# 1997.10.24 Takaaki.Tateishi

class Wish
	def init
		@wish = open("|wish","r+")
	end		

	def replace(str)
		line = str.split(" ")
		arg = []
		for i in 0 .. (line.length-1)
			if line[i] =~ /$[a-zA-Z0-9_]+/ then
				line[i] = eval(line[i])
			end
		end
		line.join(" ")
	end

	def command(str)
		@wish.write("set tcl_result [" + replace(str) + "]\n")
	end

	def close
		self.command("exit")
		@wish.close
	end
end
--------------------------------------------------------------
--------------------------------------------------
Takaaki Tateishi [tateishi@pluto.dti.ne.jp]
		 [http://www.pluto.dti.ne.jp/~tateishi]
--------------------------------------------------        			      
				      

In This Thread