Solved

Saving Records

Posted on 2001-07-15
6
180 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
creating manifest for my dll that called from activex 6 111
Intraweb download file link ? 1 132
Multi-layered image in FireMonkey 9 30
Delphi: making a BW image transparent 10 35
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now