digao-dalpiaz / DzMiniTable

Delphi non-visual component to handle small dynamic table stored as plain text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DzMiniTable

Delphi non-visual component to handle small dynamic table stored as plain text

Delphi Supported Versions Platforms Auto Install VCL and FMX

ko-fi

Please, checkout my new component DzXMLTable, it's a new concept of this component, storing data in XML format.

What's New

  • 09/12/2021 (Version 1.8)

    • Delphi 11 auto-install support.
Click here to view the entire changelog
  • 03/13/2021 (Version 1.7)

    • Removed CompInstall.exe from component sources due to AV false positive warning (now you can get it directly from CompInstall repository).
  • 02/01/2021 (Version 1.6)

    • Removed Delphi XE2 from the list of environments as it was never possible to compile in this version.
  • 12/18/2020 (Version 1.5)

    • Updated Component Installer app (Fixed call to rsvars.bat when Delphi is installed in a path containing spaces characters).
  • 10/31/2020 (Version 1.4)

    • Included Delphi 10.4 auto-install support.
  • 10/27/2020 (Version 1.3)

    • Fixed previous Delphi versions (at least on XE2, XE3, XE4 and XE5) package tag. It was causing package compilation error.
  • 10/26/2020 (Version 1.2)

    • Updated CompInstall to version 2.0 (now supports GitHub auto-update)
  • 10/09/2020 (Version 1.1)

    • New methods to search data
  • 05/03/2020

    • Updated CompInstall to version 1.2
  • 02/11/2019

    • Include auto install app
  • 02/08/2019

    • Component renamed. Please full uninstall previous version before install this version. ⚠️
  • 02/07/2019

    • Add Win64 support (library folders changed!) ⚠️

Component Description

When you are working on your software project, you always need to store some data into a INI file or some text file, as a configuration file or other information.

So, the options you have is INI file, or plain text. And almost always you need a table with some fields.

In a plain text, you can use one record per line, and separate fields using tab character, or pipe character, or another one. But you have some problems with this method: you need to take care about the separator char, not using it at fields value; and you have a biggest problem: in a future version, if you need to add a column, you lose the compatibility at this file when there are already data stored.

If you are working with INI file, you can specify the field names, but even that, you have problems to store one record per section, and is difficult to reorder records, delete records and name the record.

But don't worry, here is the solution.

The MiniTable is a non-visual component where you can store records with fields and values, and you can name the field, so you don't need to worry at future versions. You can add new fields at any time, just reading and writing them.

Installing

Auto install

  1. Download Component Installer from: https://github.com/digao-dalpiaz/CompInstall/releases/latest
  2. Put CompInstall.exe into the component repository sources folder.
  3. Close Delphi IDE and run CompInstall.exe app.

Manual install

  1. Open DzMiniTable package in Delphi.
  2. Ensure Win32 Platform and Release config are selected.
  3. Then Build and Install.
  4. If you want to use Win64 platform, select this platform and Build again.
  5. Add sub-path Win32\Release to the Library paths at Tools\Options using 32-bit option, and if you have compiled to 64 bit platform, add sub-path Win64\Release using 64-bit option.

Supports Delphi XE3..Delphi 11

Published Properties

AutoSave: Boolean = Enables auto save to specified FileName at any method that writes any change to the table

FileName: String = Specifies the full file name to Open and Save the table

JumpOpen: Boolean = When this property is enabled, if the file does not exist at Open method, the table will be loaded empty without raise any exception.

Public Properties

Lines: TStringList = Allows you to change the stored table manually. You should never change this TStringList.

MemString: String = Allows you to load the table directly from a string, and store the table to a string. This is useful when you are storing the table in a database blob file.

SelIndex: Integer = Returns the current selected index (read-only property)

Count: Integer = Returns the record count of the table (read-only property)

F[FieldName: String]: Variant = Read/write a field value at current selected record. The FieldName is case-insensitive. If you are reading field value and the field does not exist, the result is an empty string.

Procedures/Functions

procedure SelReset;

Resets the selection of record to none. You can use this method to initialize an iteration of record, ensuring the selected record is reseted.

function InRecord: Boolean;

Returns true if there is a record selected

procedure Open;

Load the table from file specified at FileName property

procedure Save;

Save the table to file specified at FileName property

procedure EmptyTable;

Clear all data in the table

procedure EmptyRecord;

Clear all data in the current selected record

function IsEmpty: Boolean;

Returns true if the table is empty

procedure Select(Index: Integer);

Select the record by index position. When you select a record, all its fields stays stored at internal memory, so you can read and write the fields value using F property.

procedure First;

Select the first record in the table

procedure Last;

Select the last record in the table

function Next: Boolean;

Select the next record in the table, based in the current index position. This method is useful to iterate all record. See example below:

DzMiniTable.SelReset;
while MiniTable.Next do
begin
  ListBox.Add(DzMiniTable.F['Name']+' / '+MiniTable.F['Phone']);
end;
procedure New;

Create a new record at the end of the table position and select it, so you can immediately start write fields.

procedure Insert(Index: Integer);

Insert a new record at the index position and select it, so you can immediately start write fields.

procedure Post;

Writes all change in the current record to the table. You don't need to start editing of the record. See example below:

DzMiniTable.New;
DzMiniTable.F['Name'] := 'John';
DzMiniTable.F['Phone'] := '1111-2222';
DzMiniTable.Post;

or:

DzMiniTable.Select(3);
DzMiniTable.F['Phone'] := '1111-2222';
DzMiniTable.Post;
procedure Delete;

Delete the current selected record

procedure MoveDown;

Move the current record to one index down

procedure MoveUp;

Move the current record to one index up

function FindIndex(const FieldName: string; const Value: Variant): Integer;

Find any field value on all records, returning record index position.

function Locate(const FieldName: string; const Value: Variant): Boolean;

Find any field value on all records, returning true if record found, and positioning it as current record. If no record is found, the current position will not be changed.

function ContainsValue(const FieldName: string; const Value: Variant): Boolean;

Find any field value on all records, returning true if record found.

function FieldExists(const FieldName: String): Boolean;

Returns true if the FieldName exists at current selected record.

function ReadDef(const FieldName: String; const Default: Variant): Variant;

This functions is the same as the F property, but here you can specify a default value when the Field does not exist in the record.

About

Delphi non-visual component to handle small dynamic table stored as plain text

License:MIT License


Languages

Language:Pascal 100.0%