Solved

Saving Records

Posted on 2001-07-15
6
185 Views
Last Modified: 2010-04-06
I am not a programmer and am working with Delphi 2 to put together a small program for myself as a learning process.

In the program i am using a record structure to keep information together such as:

Type TRList = Record
               LMark   : String[100];
               LText   : array[0..3071] of char;
               LMark2  : String[100];
               LString : String [255]
               LTrue   : Boolean;
               LNum    : Integer;
             end;

LRec:TRList;


Various input within the program is transferred to the record structure via usual means such as:

LRec.LMark:=A;

and so forth.

However with the RichEdit in the program, the text is gathered with a richedit1.lines.text command so that any line formatting is retained.  

it is then transferred to the LText array via the strpcopy(LRec.LText, richedit1.lines.text);

The record is then saved to file with the normal Write command.

Problem:

Only the first 255 characters of the richedit1.lines.text are saved to LText yet the space for the 3072 chars are allocated in the file.

Anyone know how i can solve this?  I shall give more points if required.
0
Comment
Question by:winuser2000
6 Comments
 
LVL 3

Expert Comment

by:Stefaan
ID: 6284748
Hi,

Why don't you simply use the YourRichEdit.Lines.SaveToFile and YourRich.Lines.LoadFromFile method.  They should allow you to save the contents of the RichEdit to a file and read them back in from a file.

Best regards,


Stefaan
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6284754
Hello

  why you don't change the array of char to string,like :
  LText   : string;
  instead of              
  LText   : array[0..3071] of char;

 it will handle that size and more, or u want fix size to ur project?, can you plz post some of ur code that write to file, or send me ur project at nasman@mogaza.org, and i will looking for ur project

Mohammed Nasman

 
               
0
 
LVL 17

Accepted Solution

by:
geobul earned 200 total points
ID: 6284781
Hi,
As far as I remember Delphi 2 has a string type up to 255 chars length. That's why you have got 255 chars copied only. Try the following replacement for strpcopy(LRec.LText, richedit1.lines.text); :

strmove(LRec.LText, PChar(richedit1.lines.text),Length(richedit1.lines.text));

Regards, Geo
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.

 

Author Comment

by:winuser2000
ID: 6284784
Thanks Stefaan but i am using the record structure so i can keep all of the data in one file instead of saving several files.

Mnasman, The record structure does not allow me to change LText to string and it is not a set length by which each record can be set within the file.  I am using the normal Write (f,LRec) command to write the record to the file.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6284791
I have Delphi 5, and I test that and it works with me
mmm, can you send me a copy of ur project, i will find machine that has delphi2 and will test ur project there, there are many changes happen to delphi from 2 to 5
0
 

Author Comment

by:winuser2000
ID: 6287944
Thanks Geo - that answer was short but oh so sweet and it did the trick.

thanks to everyone else that made a comment
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 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