Start TCL- TK interpreter and manage answer

Hi
I would call a TCL TK procedure for generate a form.
In order to show the form I call TclTkLib.mainloop() but, when this is closed, Ruby script is exited and I can’t get the data (via json file).
Below a very simple Ruby script, the instructions after test aren’t executed.
require ‘tcltklib’
require ‘json’
def test
# nil, false means without Tk:
ip1 = TclTkIp.new nil, false
ip1._eval(‘source C:/ActiveTcl/source/fgen.tcl’)
ip1._eval(‘formGen C:/Sviluppo/Ruby/params.txt j.json’)
TclTkLib.mainloop()
end
test
file = File.read(‘j.json’)
data = JSON.parse(file)
data.each do |key, value|
puts “#{key}: #{value}”
end
Thanks