Re: [BLACKBOX] INI files

From: [at]} <Rainer>
Date: Sat, 21 Jul 2012 06:17:48 +0200

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

Chris,
thanks a lot for your contribution.
The ini files part of my project is quite finished and running, but in spite of this I'm interested in your approach and I would like to learn how you did it. It might be of interest for the community too.
If it does not take too much time please let us know ...

Best regards,
Rainer

Am 19.07.2012 um 00:30 schrieb Chris Burrows:

>> -----Original Message-----
>> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>> Neubauer
>> Sent: Wednesday, 18 July 2012 11:42 PM
>> To: BLACKBOX{([at]})nowhere.xy
>> Subject: Re: [BLACKBOX] How to find out if a document is "dirty"
>>

> ....
>>
>> I should have mentioned perhaps that in my application the user will not
>> modify source code usually found in programs.
>> The application needs a bunch of parameters the user should be able to
>> modify. At first I planned to put them in a configuration file like this

> one:
>>
>> [ClimateChamber]
>> Enabled=TRUE
>> MinTemp=-50
> ...

> ...
>> For the user this is very ugly to maintain and error prone, and for me it

> means
>> to develop a program which would interpret this stuff, that means, first
>> checking for presence of all parameters and then checking all types and
>> values. Because from time to time the number of these parameters will
>> change, I would have to change my program too.
>>

>
> This is a fairly common task that justifies a standard library module. I
> described an alternative approach which I use regularly in a reply to this
> mailing list back in 2006. It's a good simple example of the usefulness of
> Oberon's / Component Pascal's 'type extensions':
>
>> 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?
>>

>
> 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
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-612172294_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGZiaWRpcyBcZGVmZjB7XGZvbnR0YmwN
CntcZjBcZnN3aXNzIEFyaWFsO30NCntcZjFcZm1vZGVybiBDb3VyaWVyIE5ldzt9DQp7XGYyXGZu
aWxcZmNoYXJzZXQyIFN5bWJvbDt9DQp7XGYzXGZtb2Rlcm5cZmNoYXJzZXQwIENvdXJpZXIgTmV3
O319DQp7XGNvbG9ydGJsXHJlZDBcZ3JlZW4wXGJsdWUwO1xyZWQwXGdyZWVuMFxibHVlMjU1O30N
Clx1YzFccGFyZFxwbGFpblxkZWZ0YWIzNjAgXGYwXGZzMjAgQ2hyaXMsXHBhcg0KdGhhbmtzIGEg
bG90IGZvciB5b3VyIGNvbnRyaWJ1dGlvbi5ccGFyDQpUaGUgaW5pIGZ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3dzXHBhcg0KPiBDRkIgU29mdHdhcmVccGFyDQo+IGh0dHA6Ly93d3cu
Y2Zic29mdHdhcmUuY29tL2dwY3BccGFyDQo+IFxwYXINCj4gXHBhcg0KPiAtLS0tXHBhcg0KPiBU
byB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9Y
IiB0byBMSVNUU0VSVkBMSVNUUy5PQkVST04uQ0hccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0K
VG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JP
WCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9OLn19ADogUmU6IA=
----boundary-LibPST-iamunique-612172294_-_---
Received on Sat Jul 21 2012 - 06:17:48 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:00 UTC