[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Looking for help implementing static variables

Joel VanderWerf

8/29/2007 8:59:00 PM

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/p...

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407