- Settings

From: CFB Software <"CFB>
Date: Sat, 9 Dec 2006 10:45:07 +1030

----boundary-LibPST-iamunique-3657229_-_-
Content-type: text/plain

> -----Original Message-----
> From: blackbox{([at]})nowhere.xy
> Behalf Of Alexander Iljin
> Sent: Thursday, 30 November 2006 6:37 PM
> To: BlackBox Mailing List
> Subject: [BlackBox] - Settings
>
>
> Hello!
>
> Is there a standard way in BlackBox for keeping program's settings
> between runs?
> HostRegistry is not a good idea, because it is not portable.
> I'm talking about some sort of configuration files, like ini-files?
> Did anyone work with those? Do you have any modules of subsystems
> you could share?
>

Hi Alexander,

I don't know about a standard way for BlackBox but I've done some work
on this using GPCP and have designed a system that can be
interchangeable between Ini files and Registry keys. The following
snippet should give you a feel for how it works:

VAR
  formHeight: IniFile.IntegerItem;
  formTitle: IniFile.StringItem;
  maximised: IniFile.BooleanItem;
  list: IniFile.List;
  
BEGIN
  NEW(list);
  IniFile.Init(list, 'test.ini');

  (* Associate INI file keys with program variables and default values
*)
  list.AddInteger('Form Height', formHeight, 400);
  list.AddString('Form Title', formTitle, 'Test Program');
  list.AddBoolean('Maximised', maximised, TRUE);

  (* Read the contents of the INI file and assign values to the program
variables *)
  list.Load();
...
...
...
  formHeight.value := formHeight.value + 20;
  formTitle.value := formTitle.value + ' v1.0';
  maximised.value := ~ maximised.value;

  (* Write the updated values to the INI file *)
  list.Save();

 
With the above code, if the initial IniFile, 'test.ini', had the
contents:

  Form Height = 420
  Maximised = FALSE

After executing the code the IniFile would have the contents:

  Form Height = 440
  Form Title = Test Program v1.0
  Maximised = TRUE

It shouldn't take long to port it to BlackBox - it's mainly the text
file IO that would have to be translated. Let me know if you are
interested and I'll give it a go.

Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy


----boundary-LibPST-iamunique-3657229_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGF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2VkID0gVFJVRVxwYXINClxw
YXINCkl0IHNob3VsZG4ndCB0YWtlIGxvbmcgdG8gcG9ydCBpdCB0byBCbGFja0JveCAtIGl0J3Mg
bWFpbmx5IHRoZSB0ZXh0XHBhcg0KZmlsZSBJTyB0aGF0IHdvdWxkIGhhdmUgdG8gYmUgdHJhbnNs
YXRlZC4gTGV0IG1lIGtub3cgaWYgeW91IGFyZVxwYXINCmludGVyZXN0ZWQgYW5kIEknbGwgZ2l2
ZSBpdCBhIGdvLlxwYXINClxwYXINCkNocmlzIEJ1cnJvd3NccGFyDQpDRkIgU29mdHdhcmVccGFy
DQpodHRwOi8vd3d3LmNmYnNvZnR3YXJlLmNvbS9ncGNwXHBhcg0KXHBhcg0KLS0tIEJsYWNrQm94
XHBhcg0KLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRvIGJsYWNrYm94QG9i
ZXJvbi5jaH19ABRhDJ4UYb6jEBk=


----boundary-LibPST-iamunique-3657229_-_---
Received on Sat Dec 09 2006 - 01:15:07 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:32:03 UTC