💡 LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering
Download Trial
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 #module
file: "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 #module
file: "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.
Advertisement