----boundary-LibPST-iamunique-626207205_-_-
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?
>
> PS: I know about Dialog.MapString, but I found no predefined way to
> _store_ changed information back into strings resource file.
>
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
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-626207205_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.r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