Parameter passing across two files
-
Hello,
can somebody say how to pass a parameter across two files in ruby?
To be exact it's a variable, which contains a string.
The string changes its value at the runtime.
Is there a problem with sketchup?Thank you.
-
file: "chris88/chris88_mod.rb"
module Chris88 @@common_var_name = "some string value" # create a getter method for @@common_var_name # def self.common_var_name() return @@common_var_name end #def method end #modulefile: "chris88/plugin_one.rb"
require("chris88/chris88_mod.rb") module Chris88;;PluginOne local_var_name = Chris88.common_var_name() # local_var_name is pointing at the SAME string object that # Chris88;;@@common_var_name is also pointing at. # If you wish a copy then; local_var_copy = Chris88.common_var_name().dup end #modulefile: "chris88/plugin_two.rb"
require("chris88/chris88_mod.rb") module Chris88;;PluginTwo puts( "The value of my common string is; #{Chris88.common_var_name()}" ) end #module -
Great!
Thank you Dan.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement