Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write From Memo Box to File

Status
Not open for further replies.

gforrest

Programmer
Apr 26, 2000
39
CA
Hi Guys,

I'm using the following code to read some info from a file into a Memo Box and then write new info from the Memo Box back to the file. The read portion under Form Activate works OK but when I attempt to write using the 'EdtLgOkBtnClick' procedure I get an, "Access Violation" error. Any thoughts on how to cure this would be appreciated.

procedure TEdtLgFrm.FormActivate(Sender: TObject);
var
val : Integer;
RecINFO : INFO;
i : Integer;
StrArray : Array[0..40] of Char;
PStrArray : PChar;

begin
PStrArray := @StrArray;
EdtLgMb.Clear;
for i := 0 to 7 do
begin
read_options(@RecINFO);
Move(RecInfo.Logo[i,0],StrArray[0],41);
EdtLgMb.Lines.Add(string(PStrArray));
end;
end;

procedure TEdtLgFrm.EdtLgOkBtnClick(Sender: TObject);
var
RecINFO : INFO;
i : Integer;
StrArray : Array[0..40] of Char;
PStrArray : PChar;
begin
if EdtLgMb.Lines.Text = '' then
begin
ShowMessage('Please Enter New Logo Information or Press EXIT');
Exit;
end
else
read_options(@RecINFO);
EdtLgMb.Lines.Add(string(PStrArray));
Move(RecInfo.Logo[i,0],StrArray[0],41);
write_options(@RecINFO);
end;

end.
 
Um, why not use the behavior built into the tStringList ancestor for the Lines property?
Specifically, look at the loadFromFile and saveToFile methods of your memo object's Lines property?

Hope this helps...

-- Lance

 
You make a good point.

The reason I can't do this is because I access the file via a Delphi record (structure) that talks to a DLL written in 'C'. The information that I want is stored as an Array of Char.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top