Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Borland Delphi > String access e...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 3663 of 3830
Post > Topic >>

String access error in class

by E Sterrett <bgreenf@[EMAIL PROTECTED] > Mar 27, 2008 at 08:01 PM

I have included a stripped down version of a class I am using to store 
configuration data in an ini file.

This works when I am using it from a simple console app. But when I 
include it in a larger project, the constructor throws this error:

'Access violation at address 004050FC in module 'app.exe'. Write of 
address 00000008'.

This happens on the line:  ComputerName:='test';

Obviously 00000008 is not a valid address. But I thought delphi handles 
string address automatically.

What have I done wrong?

Thanks.



unit Configuration;

interface

uses windows,inifiles,sysutils;

type
TConfig = Class(TObject)
     public
       FileName:string;

       ComputerName:String;
       //...

       constructor Create(); overload;
       constructor Create(FN:String); overload;

       //procedure saveFile(); overload;
       //procedure saveFile(FN:string); overload;

       //function checkErrors():string;
       //procedure fixErrors();


   end;


var

   IniFile : TIniFile;

implementation

constructor TConfig.Create(Fn:string)overload;
begin

   IniFile := TIniFile.Create(Fn);
   ComputerName:='test';

   filename:=fn;
   //savefile(fn);

end;

constructor TConfig.Create()overload;
begin
   Create(Paramstr(0)+'.ini');
end;

end.
 




 5 Posts in Topic:
String access error in class
E Sterrett <bgreenf@[E  2008-03-27 20:01:37 
Re: String access error in class
Jamie <jamie_ka1lpa_no  2008-03-27 19:07:48 
Re: String access error in class
"Maarten Wiltink&quo  2008-03-28 00:33:29 
Re: String access error in class
E Sterrett <bgreenf@[E  2008-03-28 00:24:13 
Re: String access error in class
"Maarten Wiltink&quo  2008-03-28 11:31:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 10:11:58 CDT 2008.