From: Ralph Mason Date: 2001-12-30T04:43:31+09:00 Subject: [ruby-talk:29644] Re: putting contents of variable into a string You need to use #{v} rather than (#v) Ralph ----- Original Message ----- From: "Paul Vallance" Newsgroups: comp.lang.ruby To: "ruby-talk ML" ; Sent: Sunday, December 30, 2001 8:36 AM Subject: [ruby-talk:29643] putting contents of variable into a string > Dear ruby users > > This doesn't work in ruby 1.6.5 in windows. If I receive some data > from a TCP server and put it into a variable (v), remove some trailing > text and a carriage return, and then try to put the contents of v (#v) > into a subsequent send string ( "/ispicbox(#v)\n" ) I get nothing > returned from my server (ie @boxtype = nil). Have cross checked my > server softwares and its OK. > > regards > Paul Vallance > > code follows..... > > #!/usr/bin/env ruby > > require 'socket' > > > t = TCPSocket.new("192.168.0.100",13) > @data = t.recv(110) > puts @data > t.send("/createdoc(Box ID test,210 mm,297 mm,0 mm,0 mm,0 mm,0 mm, > 0,1,0,0)\n",0) > @data = t.recv(30) > puts @data > t.send("/newbox(4,0 mm,0 mm,150 mm,210 mm,0)\n",0) > @data = t.recv(30) > puts @data > t.send("/firstbox\n",0) > @readdata = t.recv(30) > puts @readdata // check value on console > v = @readdata > v.gsub!(/TCP\/XT OK/, "") //remove TCP/XT OK > v.chop! //remove Carriage return > puts v // check value on console > t.send("/ispicbox(#v)\n",0) > @boxType = t.recv(30) > puts @boxtype > t.close >