Re: Open / save / save as in Delphi

Posted by webmaster Guido on May 04, 2005

In Reply to: Menu Component ( Open, Save, Save as, Print, Close) posted by Lionel Joyner on May 02, 2005:

: I am working on an Delphi application that performs some computations and displays the results in a ListBox.
: ... but do not know how to Save the Results to a folder on a disk or hard drive or Save the File As something other than text or Open the File once it is saved.

Saving the results in a text file is simple, as you've probably found out already. Because you have them in a ListBox, you can use:
ListBox1.Items.SaveToFile('c:\results\data.txt')

Saving other data then text, requires that you use some form of database:

1. Use a desktop database that is supported by Delphi, such as Paradox or dBase. For this, you need a Delphi version with the database components: D4 Pro and higher, D5 Pro, D6 Pro,...
In that case, it's very simple and we can guide you throught the process :)

2. If you don't have the database stuff in your version of Delphi, you have to create a simple database system of your own, based on text files.
Before writing data, all your data values are converted to text, "fields" are separated separated by a special character, and each "record" is on a separate line of the text-file. Example with semicolon ; as separator:

record1;12.500;50.888;0.15
record2;11;17.98888;1.588
and so on...

When reading back, you split up each line into strings and convert these strings to their original format (numbers, dates,...)

Which way do you want to go?
Greetings,
Guido

Related Articles and Replies

Turbo Delphi Explorer
Database programming with the latest FREE Delphi version. Download and install!
     

 

Delphi Forum :: Tutorials :: Source code :: Tips