Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: A new TIniFile writer



Permlink Replies: 2 - Last Post: Jan 18, 2015 6:31 AM Last Post By: Lajos Juhasz
Colin Maharaj

Posts: 122
Registered: 12/2/99
A new TIniFile writer
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2015 4:22 AM
Is it possible to propose a new TIniFile in the VCL and here is what I am proposing.
The best way is to show the code in use.....

//-----------------------------------------------------------------------------
// Some arbitrary values
//-----------------------------------------------------------------------------

int MaxFiles;
bool UseDualCoreSort;
AnsiString CompanyName;
char emailAddress[128];

//-----------------------------------------------------------------------------
// The code in use
//-----------------------------------------------------------------------------

void Settings(bool read)
{
AnsiString My_ini = "my.ini";
TIniFile2 * I = new TIniFile2 (My_ini);

I->Load = read;

I->Integer ("Reports" , "MaxFiles" , MaxFiles , 16384);
I->Bool ("Reports" , "UseDualCoreSort" , UseDualCoreSort , false );
I->String ("Startup" , "CompanyName" , CompanyName , "Colin Inc");
I->CString ("Startup" , "Email" , emailAddress , 128, "colin at mycompany dot com");

delete I;
}

//-----------------------------------------------------------------------------
// The possible use cases.....
//-----------------------------------------------------------------------------

#define IniRead true
#define IniWrite false

Settings(IniRead); // read values from Ini file
Settings(IniWrite); // Write values to Ini file


So if Load is true, you are reading the values.
If it is false, then you are writing the values.

In this way ...

1) You don't have to have a separate code to read and write settings.
2) There will be less possible error in specifying the header and section names.
2.1) Technically specifying the header and section twice is duplication.
3) You are specifying the default values right in the line that does the reading/writing.

In the case of the cstring, you are specifying the length so that the reader will
not overwrite the cstring .

Finally, maybe something similar can be done for the Registry as well.

Comments?

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: A new TIniFile writer
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 17, 2015 12:06 PM   in response to: Colin Maharaj in response to: Colin Maharaj
Hello,

if you want to propose this you should either create a new QC report in
QC or better a report in the new Quality Portal at quality.embarcadero.com

Posting that one here doesn't get you anywhere with it I fear.

Greetings

Markus
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: A new TIniFile writer
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 18, 2015 6:31 AM   in response to: Colin Maharaj in response to: Colin Maharaj
Colin Maharaj wrote:

Finally, maybe something similar can be done for the Registry as well.

Comments?


This will not work with object properties (can not pass a property as a
var parameter.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02