Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving Records

Posted on 2001-07-15
6
Medium Priority
?
213 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 800 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

927 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