Article View: borland.public.cppbuilder.nativeapi
Article #8245Re: TIniFiles
From: Lothar
Date: Fri, 05 Nov 2004 13:34
Date: Fri, 05 Nov 2004 13:34
97 lines
4038 bytes
4038 bytes
Hi David,
thank you for these valuable sugestions. That all will help to make my
program better and clearer.
But still, what's about my question?
When I write I get an exception:
Unable to write to D:\SpeedraTel\PROGRAMME\SpeedraTest.ini at 0x0
This procedure TestINI() is just to find out when the problem in the
program occurs. Then it starts the program new. But that's not a real
solution.
You have any idea why I get an exception? What can be the reason?
Thank you
Lothar
David Scheffel schrieb:
>Hi Lothar,
>
>I don't feel like your application is well designed right now. There are a
>lot of things that should be improved basically. E.g. the following:
>
>1.) don't use static char arrays, use AnsiString instead
>2.) since sprintf is unable to throw exceptions you should use Format
>instead
>3.) you don't need to check if pIniFile is null after you have constructed
>it! pIniFile is NOT an handle to an IniFile!! It is an pointer that points
>to an instance of TIniFile. If the ctor of TIniFile runs into an error it'll
>throw an Exception anyway
>4.) avoid the use of timers unless it's really necessary. You should read
>the settings when the application is constructed. If you have only a single
>form or MDI Main Form you could read the settings the the ctor of the form
>
>Further more I'd recommend you to read at least one of these books: "Borland
>C++Builder 4 Unleashed", "C++Builder 6 Developer's Guide". If you're still
>unhappy with TIniFile you might have o look at TMemIniFile which works
>independant from windows and is much faster since it hold the data in the
>memory.
>
>regards
>//David
>
>
>
>>void CPtimer::TestINI()
>>{
>> TIniFile *pIniFile;
>> char DisplayStr[200];
>>
>> if (!TestINIok) return;
>>try {
>> try {
>> pIniFile = new
>>TIniFile(ExtractFilePath(ParamStr(0))+"SpeedraTest.ini");
>> if (pIniFile) {
>> pIniFile->WriteDateTime("Test",TestINIstart, Now());
>> sprintf(DisplayStr,"TestINI ok %d",pIniFile);
>> Display(DisplayKanalx,DisplayStr);
>> } else {
>> DisplaySystemError(DisplayKanalx,"TestINI Fehler");
>> TestINIok=false;
>> Form1->EndeundNeustartwennohneAnruf->Checked= true; // new start
>>of program
>> }
>> } catch(const Exception& e) {
>> DisplaySystemError(DisplayKanalx,"Exception TestINI");
>> sprintf(DisplayStr,"!!!Exception: %s at
>>0x%X",NoSteuer(e.Message).c_str(),ExceptAddr());
>> Display(DisplayKanalx,DisplayStr);
>> TestINIok=false;
>> Form1->EndeundNeustartwennohneAnruf->Checked= true; // new start
>>of program
>> }
>>
>> delete pIniFile;
>>} catch(const Exception& e) {
>>}
>>}
>>
>>
>>David Scheffel schrieb:
>>
>>
>>
>>>Could you post the source code?
>>>
>>>
>>>
>>>
>
>
>
>
Technical Details
Message-ID:
<418b818c$3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4189f894$1@newsgroups.borland.com> <418a15ad$1@newsgroups.borland.com> <418a22f5$2@newsgroups.borland.com> <418b6cf9$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,db95008868615205 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 05 Nov 2004 14:34:27 +0100 From: Lothar <Lothar.Huppertz@gmx.de> User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; de-DE; rv:1.4) Gecko/20030619 Netscape/7.1 (ax) X-Accept-Language: de-DE, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: TIniFiles References: <4189f894$1@newsgroups.borland.com> <418a15ad$1@newsgroups.borland.com> <418a22f5$2@newsgroups.borland.com> <418b6cf9$1@newsgroups.borland.com> In-Reply-To: <418b6cf9$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 80.133.140.88 Message-ID: <418b818c$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099661708 80.133.140.88 (5 Nov 2004 05:35:08 -0700) Lines: 98 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail