From: Robert Klemme Date: 2007-07-31T17:30:40+09:00 Subject: Re: Passing variables to a required file 2007/7/30, 12 34 : > I want to pass about 10 variables to a "require"d file. My understanding > is that I need to use global variables. Is this correct? > > I'm reluctant to change all the variables to global for fear of messing > up the methods in the script. I can of course define new global > variables equal to the local variable. Seems inelegant. > > I guess my best option is to rework the require'd file as a method, but > my script is getting long and keeping the file separate makes sense, > particularly since it is creating the GUI, so is different from the > script function if I understand the MVC philosophy. > > Is there a better way? FWIW I'm "require'ing a modified example.rb file > that is included in the Pashua app for creating a simple GUI for OS X. > > > Thanks for info > > PS The example file as a > > Config = < > > EOS > > I can't find EOS in Ruby on Rails or PickAxe, so maybe I'm missing > something in how it's used. I'd suggest to refactor your code so you have multiple classes and can instantiate them with appropriate parameters. Storing code in a long string is a bad option if the code is known at compile time which seems to be the case here. Kind regards robert