Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Saving Records

Posted on 2001-07-15
6
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

721 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