Solved

TRegIniFile.Create('') fails in D6

Posted on 2002-07-04
10
323 Views
Last Modified: 2010-04-04
I often used TRegIniFile and declared
var
  RegItem: TRegIniFile;

and did
  RegItem := TRegIniFile.Create('');

Which fails in D6.

I've got round it by using TRegistry and declared
var
  RegItem: TRegistry;

and doing
  RegItem := TRegistry.Create;

But TRegIniFile.Create('') always worked OK in D5 and below as far as I remember. Just tested and still works OK in D5 on same system.

Is this a D6 bug or was I doing something wrong until D6 stopped me?

I have Delphi 6 sp2 installed and running on winxp.
I searched but have not found anything relevant so far.

Anyone know what is going on here?

Regards
Steve


0
Comment
Question by:SteveWaite
  • 6
  • 2
  • 2
10 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7130652
Hello Steve

>> Which fails in D6.

what do u mean by that?, it's working fine with me in Delphi 6 and win XP, r u sure that u add Registry to the uses clause?
and what's the error message you got?

aslo why u don't use TRegistry instead of it?



0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7130665
Hi Mohammed,

Thanks,

Registry is added to uses clause ;-), but I did say I just run the whole thing in D5 and worked fine!

I do use TRegistry but found this from a section that writes .ini files as well.

No error message, just silently leaves the procedure on the line

  RegItem := TRegIniFile.Create('');

Are you sure you do the same thing, declare a file of no name?

Regards
Steve
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7130739
yes
i just copy what u wrote exactly and it worked fine without any errors
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

by:SteveWaite
ID: 7130795
Strange?!

I have D6 pro
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7130850
Now in unit Registry..

function IsRelative(const Value: string): Boolean;
begin
  Result := not ((Value <> '') and (Value[1] = '\'));
end;

IsRelative() fails at Value[1] because Value = ''

So I went to 'complete boolean eval' and needed unchecking so that ((Value <> '') prevents the computation of (Value[1] = '\').

This still works ok in D5!! the 'complete boolean eval' setting makes no difference to IsRelative().

So now I ask the same question but a different way:

Why with D6 must we have 'complete boolean eval' unchecked for code in the Registry to work when it was fine in D5 checked or not? What is is causing this?



0
 
LVL 8

Expert Comment

by:TOndrej
ID: 7131057
Not to use complete Boolean evaluation is the default.
In D5, you're probably using the .dcu supplied by Borland which was compiled with {$B-}.
In D6, you're probably compiling your own new .dcu.
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7131905
Thanks TOndrej,

Exactly! Now why, all of a sudden, am i compiling my own .dcu?
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 100 total points
ID: 7131948
Because the .dcu file is not found or the .pas file is found sooner.
Check your paths.
The .pas directory probably appears in your library path before the .dcu directory; or maybe the .dcu directory is missing in your library path.

IMO you should not have the .pas directory included in your library path at all; remove it if it's there.
The same applies to your Project Options search path.
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7131975
ok, having a look, back soon.
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7131988
Woah! The .pas dir was slipped in there but hey, it wasn't me!

Thanks TOndrej, you have it this time, Mohammed thanks for your time too.

Regards
Steve
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question