Site hosted by Angelfire.com: Build your free website today!

Lazarus DataReader. Reads DBase files up to 7.

Open Lazarus.
Drop a Button and Edit component, from the Standard tab, on the form.
Drop a OpenDialog component onto the form.  
Drop a DBNavigator and a DBGrid components, from the Data control tab, on the form.  
Drop a DataSource and a Dbf components, from the Data Access tab, on the form.  
Click on the form, not on any of the components. In the Object Inspector (OI). 
The form will now be in focus.
In the Caption  = Dataread ver. 1.0.1 .

Click on the Button in the OI window Caption = Open. Click on the Edit1 component, in the OI window, under the Properties tab, Text delete the text. (press the Delete key). Click on the OpenDialog component in OI -> Filter button to the right [...] click it. Under Filter name type DBase File Under Filter type *.dbf Then the OK button. This will only show files with the extension of .dbf . The default for DBase files. Click on the DataSource component. DataSet = Dbf1. Click on the DBNavigator component. DataSource = DataSource1. Under DBNavigator -> Properties ->VisbleButton click the triangle to the left. This will expose a dropdown. Unchecke nbCancel, nbDelete, nbEdit, nbInsert, nbPost, and nbRefesh. Click on the DBGrid component. DataSource = DataSource1. Save the project. At top of Lazarus window, Project -> Save Project As. Save the project file .lpi as Dataread.lpi and Unit1.pas as Unit1.pas. Close to the top of the Unit1.pas code you could add Filename,Path,FileN: String; under var Form1: TForm1;. var Form1: TForm1; Filename,Path,FileN: String; This would make these Valuables Global, Can be used and changed through the life of the program. (Use Global Variables sparingly), but we do not need Global Variables. So, We will not do this. we will make the Valuables Local, to the procedure(). good for the life of the procedure. Double-Click on the Open Button. This will open the code editor and place the cusser at the procedure (function) for the button. -- Comment you code. Reusing, Redoing and Fagoting code is a big part of programming. --- ///Open button. procedure TForm1.Button1Click(Sender: TObject); var ///Creates 3 local variables. all are Strings. Filename,Path,FileN: String; begin ///Opens file dilog and /// Copy the path and filename to Filename. if OpenDialog1.Execute then begin Filename := OpenDialog1.FileName; end; ///Copy the path and filename to Edit1. Edit1.Text:=Filename; ///Extracts the Filename from the path and filename. FileN := ExtractFileName(Filename); ///Extracts the path from the path and filename. Path := ExtractFilePath(Filename); ///Copys the path into Dbf1's FilePathFull. Dbf1.FilePathFull:=Path; ///Copys the Filename into Dbf1's TableName. Dbf1.TableName:=FileN; ///Activates the Dbf1 componit. Dbf1.Active:=True; end; --Save project Project -> Save Project. Press F9 or the green triangle.


How to use

You will need a DBase 3, 3+, 4, or 7 DBase file. I do not know about 5.
Lazarus has a couple in the example directory. 
If you do not know where the example directory is.
Click on Tools -> Options under Envelopment -> Files under Lazarus Directory. Is the root Lazarus directory.
In my case it is /usr/local/lib/lazarus/ so /usr/local/lib/lazarus/examples/database/dblookup/data
There is lookerup.dbf and months.dbf . The mbf files are Multiple index file backup.
In windows it is D:\Programming\Lazarus so D:\Programming\Lazarus\examples\database\dblookup\data .
If there is an image or memo. This program will not display either. It will show the column 
and (BLOB) for An image or (blob) if there is not an image. Memo is (MEMO) for memo and (memo) for no memo.
   

Gary Russell (ISSW)
ghrussell@yahoo.com
https://russellman128.angelfire.com/
Nov 29 2017

.