TBag manages user preferences via an INI file section.

This code belongs to me (Mike Orriss), but you are free to use it as you wish
without any payment. I would ask however for your feedback and any suggestions
for additional functionality (or even code!).

It will be posted to the libraries (eventually) but it needs a help file,
proper tea-bag icon (any volunteer? - as I'm no artist!) and more
documentation first.

Usage:
1) Add UBag.Pas to your component palette  *or*
2) You can use by adding UBag.Pas to a project and then issue:
        uses UBag;
        var Bag: TBag;
        Bag := TBag.Create(nil);
        Bag.IniFile := ......
        Bag.IniSect := .......
           ......
        Bag.Free


Any problems or comments: contact Mike Orriss (3K Computer Consultancy):
Compuserve: 100570,121
Fax: +44 (0)1785 824056
Phone: +44 (0)1785 824053


Release 1.1 Notes
-----------------
New procedures:
        GetFormPlace(Ref: string; AForm: TForm);
        SetFormPlace(Ref: string; AForm: TForm);

Use GetFormPlace in FormCreate or FormShow and SetFormPlace in FormClose in
order to retain form size, position and mode.
Note: does not support opening of main form as minimised.

Example (assuming Prefs is a TBag with properties set):
FormShow:
        Prefs.ReadIni;
        Prefs.GetFormPlace('FORM1_PLACE',Self);
FormClose:
        Prefs.SetFormPlace('FORM1_PLACE',Self);
        Prefs.WriteIni;

Note that you can handle other forms by casting as TForm:
        Form1.Prefs.SetFormPlace('FORM2_PLACE',Form2 as TForm);


Release 1 Notes
---------------
Standard usage:

1) set IniFile & IniSect properties
2) Call ReadIni method in FormShow
3) Use GetXXXX & SetXXXX methods
4) Call WriteIni method in FormClose

Note that the INI section & INI file do not have to exist as all
GetXXXX methods require a default parameter.

GetXXXX format:  GetXXXX(Ref: string; Default: TXXXX): TXXXX;
SetXXXX format:  SetXXXX(Ref: string; Value: TXXXX);

XXXX types supported: String, Integer, LongInt, Boolean, TColor, TFont

There is another 'Get' method:
                 GetByIndex(Index: integer; var Ref,Value: string);

Other procs & functions:

  Clear;  {removes all entries from Bag}
  Count: integer;  {number of Bag entries}
  DeleteIni;  {empties INI section}
  DelValue(Ref: string);  {removes entry from Bag}

Example:
  var ix: integer;
  sName,sValue: string;

  with TBag.Create(nil) do try
    IniFile := 'c:\windows\system.ini';
    IniSect := 'DRIVERS';
    ReadIni;
    for ix := 1 to Count do begin    { note that it starts with 1}
      GetByIndex(ix,sName,sValue);
      ListBox1.items.add(sName+'  =  '+sValue);
    end;
    Inifile := 'c:\temp.ini';
    Inisect := 'XXXXXX';
    WriteIni;
  finally
    Free;
  end;
