🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8243

Re: TIniFiles

#8243
From: David Scheffel
Date: Fri, 05 Nov 2004 12:07
67 lines
3250 bytes
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: <418b6cf9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4189f894$1@newsgroups.borland.com> <418a15ad$1@newsgroups.borland.com> <418a22f5$2@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
From: "David Scheffel" <noreply@spammy.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4189f894$1@newsgroups.borland.com> <418a15ad$1@newsgroups.borland.com> <418a22f5$2@newsgroups.borland.com>
Subject: Re: TIniFiles
Date: Fri, 5 Nov 2004 13:07:16 +0100
Lines: 69
Organization: Novaris Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 212.227.35.73
Message-ID: <418b6cf9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1099656441 212.227.35.73 (5 Nov 2004 04:07:21 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail