Board index » delphi » Saving data
Rob Stevenson
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Rob Stevenson
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Saving data
Hi
I have several arrays setup some as stings and others as integers and what I want to be able to do but can't find a wa as yet is to save the data to a file so that when I close the program and the open it up again the data in the arrays is not lost but is retrived fro the file or where ever. Please could someone wrtie us a bit of code or point us to somewhere on the internet where there is an example of somethning like this or if it can't be done with pascal tell me and stop me looking for a way. Thanks in advance Rob Stevenson |
Forget
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataHey Rob, I'm sorry but i don't have the answers for you :o(, but i'm gonna be chaaky and say when u get the answers email them to me too. I'm having the same problem. Obviously when i find out i will send it on to you too! regards jo |
UKHostT
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataYou need to something like these 2 procedures : All the best, Var Procedure SaveData; Procedure LoadData; |
Jay Knigh
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataThe concept isn't really hard. First, declare a variable as 'text' (e.g. var InFile : text;) then, the very beginning of the program main should be assign (Infile,'c:\dir\file.ext'); then, if you want to write to the file, do this next rewrite (InFile); if you want to read from the file do this reset (InFile); you can either read or write and a time, not both. now, to actually do the reading and writing, do this: write (Infile, 'blah blah blah', varname); works the same with read. When you're done with the files, make sure you close (Infile); to EVERY file. If you don't, you're asking for data loss. Jay Knight |
Ing. Franz Glase
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataUKHostTIM schrieb: Quote
|
Simo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataQuoteIn article <19981123174658.12387.00002...@ng28.aol.com>, ukhost...@aol.comNOJUNK (UKHostTIM) wrote: READLN instead of WRITE and READ as when you READ a string from a file then TP will read the entire line or up to 255 chars. More efficient would be comma delimited files - depending upon the content of Read (InFile,TokenChar); (* READ FIRST LETTER OF LINE *) If your data is fixed and repeating then perhaps you should consider bunging |
Oz
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataIn article <73e1gj$n8...@bunyip.cc.uq.edu.au>, Simon <porcup...@n2.com> writes Quote>If your data is fixed and repeating then perhaps you should consider bunging that waste storage. Also it's really hard to read unless you know the format. -- |
Brent Bea
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataOn Mon Nov 23, remove wrote: Quote>I have several arrays setup some as stings and others as crucial to the success of many programs. Depending on the amount of data involved, variations on the following technique should be used. Since the file on disk need not be people readable, you may as These two procedures work on files of type FILE! var You can read/write any amount of data up to 64KB. You open/close procedure blockread(db, array1, sizeof(array1), readlen); procedure blockwrite(db, array1, sizeof(array1), writelen); Of course, you should check all return codes (reset, rewrite, This is enough provided the things in the database are simple If you are using protected mode, you may have to copy the data BTW, one thing you should do is begin the database with a The dbsave routine writes the new DB identification and the new Where the data is stored in lists in RAM rather than arrays, you Brent |
Klaas de Jo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataOn 24 Nov 1998 19:58:35 GMT, ae...@FreeNet.Carleton.CA (Brent Beach) wrote: Quote>var Quote
file. If this parameter is omitted, BP assumes a record size of 128 bytes. Results of BlockRead and BlockWrite operations can become ... interesting. regards, |
Andreas Kill
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Saving dataRob Stevenson schrieb: Quote> I have several arrays setup some as stings and others as integers and fixed as in arrays. Here is a qiuck and dirty prg: var procedure ShowArray; begin ShowArray; {-Save it to a file} {-Make the array empty} ShowArray; {-Read the data back from the file} ShowArray; By, Andreas. |