I found the solution, but it still doesn't work properly.
I use "rb_require" instead of "rb_load_file":
extern VALUE ruby_top_self;
main{
.....
rb_require(myFileName);
rb_funcall(ruby_top_self,rb_intern("work1"),1,query_list);
ruby_exec();
}
There are 3 files: test1.rb, test2.rb, test3.rb, which have the function
"work1" in them:
def work1(arr_name)
puts "test1"
end
def work1(arr_name)
puts "test2"
end
def work1(arr_name)
puts "test3"
end
I run the program and choose:
test1.rb -> test1
test2.rb -> test2
test3.rb -> test3
test1.rb -> test3
test2.rb -> test3
If you do not restart the virtual machine, it remembers which files
have already been required. Thus, if the same file is required in
various parts of your code, it is only parsed once.
Carlo
···
Subject: Re: Calling ruby function from C
Date: mar 18 mar 14 01:33:12 +0100
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)