From: Joel VanderWerf Date: 2007-08-30T05:58:33+09:00 Subject: Re: Looking for help implementing static variables Harry Truax wrote: > Hello, > > I am working on an application where we are trying to remember previous > values from an execution of a Ruby program. Basically, we have a screen > where a user can type an 'X' into either a 'Yes' or a 'No' box. We do not > want them to type Xs into both boxes. So if the 'Yes' box has an X in it, > and then the user types an 'X' into the 'No' box, we want to clear the 'Yes' > box automatically. Our Ruby program runs each time the user tabs out of a > field on the screen or presses the Enter key. This isn't built into ruby, which is probably a good thing because there are many different ways of doing it. A typical solution will involve one of ruby's standard object persistence mechanisms, either Marshal (not humanly readable, but efficient) or YAML (humanly readable, and also readable by Perl, Python, etc.). There's also the question of where to store this file. On unix/linux, you might want to use a "dot" file in the user's home dir, or in ENV["HOME"]. On windows, there is a different standard for selecting the location (ENV['APPDATA'], for example)). I wrote a small library that does this using YAML. See: http://redshift.sourceforge.net/preferences -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407