express me m data

98
Overview Known Issues and Important Changes List Getting Started ExpressMemData is an ultra-fast in-memory TDataSet descendant you can use to bind data from any data source (including text, binary, INI and many other file types) in conjunction with all existing VCL data-aware controls. ExpressMemData also supports the following: l Sorting; l Grouping (via the ExpressQuantumGrid ™); l Save or load to and from binary/text files; l Multi field Locate; l Filters. With ExpressMemData, you can create all standard field types and yes, BLOB fields are supported. You can populate ExpressMemData in three ways: l As a TDataSet , by assigning values to its fields - which is easier, and will be fully compatible when you decide to switch your ExpressMemData to a database back-end. l By accessing the internal buffers of ExpressMemData as an array. l As a TClientDataSet , by assigning data from any TDataSet descendant at design time. Possible uses for ExpressMemData include: l As a fast way to store and display data in data-aware controls. ExpressMemData also offers an easy upgrade path should you decide to move to a multi-user database at a later time. l As a temporary table, when processing complex reports (it is easier to populate ExpressMemData with your calculated records rather than designing complex reports). l As a temporary table, when doing complex editing operations - you make all the edit operations with ExpressMemData, and apply all the changes to the database at once. l As a local storage of remote data - you can allow your users to download tables to their local hard drive and then use ExpressMemData to browse the records, without the need for a live connection to the database. When you use ExpressMemData in your application, no additional DLLs are required - all the functionality is built right into your program. ExpressMemData is ideal for fast, single-user applications where you require the ability to use existing data-aware control and maintain the functionality you have come to expect such as data validation. Page 1 of 98

Upload: martin-miguel-parody-narvaez

Post on 12-Dec-2015

110 views

Category:

Documents


12 download

DESCRIPTION

Express Me m Data

TRANSCRIPT

Overview Known Issues and Important Changes List Getting Started ExpressMemData is an ultra-fast in-memory TDataSet descendant you can use to bind data from any data source (including text, binary, INI and many other file types) in conjunction with all existing VCL data-aware controls.   ExpressMemData also supports the following:

l Sorting; l Grouping (via the ExpressQuantumGrid™); l Save or load to and from binary/text files; l Multi field Locate; l Filters.

  With ExpressMemData, you can create all standard field types and yes, BLOB fields are supported. You can populate ExpressMemData in three ways:

l As a TDataSet, by assigning values to its fields - which is easier, and will be fully compatible when you decide to switch your ExpressMemData to a database back-end.

l By accessing the internal buffers of ExpressMemData as an array. l As a TClientDataSet, by assigning data from any TDataSet descendant at design time.

  Possible uses for ExpressMemData include:

l As a fast way to store and display data in data-aware controls. ExpressMemData also offers an easy upgrade path should you decide to move to a multi-user database at a later time.

l As a temporary table, when processing complex reports (it is easier to populate ExpressMemData with your calculated records rather than designing complex reports).

l As a temporary table, when doing complex editing operations - you make all the edit operations with ExpressMemData, and apply all the changes to the database at once.

l As a local storage of remote data - you can allow your users to download tables to their local hard drive and then use ExpressMemData to browse the records, without the need for a live connection to the database.

  When you use ExpressMemData in your application, no additional DLLs are required - all the functionality is built right into your program. ExpressMemData is ideal for fast, single-user applications where you require the ability to use existing data-aware control and maintain the functionality you have come to expect such as data validation.

Page 1 of 98

TdxMemData - Getting Started Overview Assume we need to create an application. In one of its modules a user can edit (edit, delete, add) the names of Internet friends.   Data Specifications: Object countries (Id, country name) and object Internet friends (Id, first name, last name, nickname, e-mail, birthday, interests and country).   We could use standard BDE tables, but for the sake of this example, assume we don’t want to use any database files, and of course, we don’t want to distribute our application with powerful, but very large DLLs.   In this instance, we have two options:

l Use only non–data aware controls. l Use TdxMemData.

  The first solution is a good one if you have lots of time or are not concerned with data validation, such as required values or correct values. Obviously, you have to do an incredible amount of work to implement controls such as lookups, etc.   Let's now show you how easy it is to use our TdxMemData to resolve just this type of a problem.  

1. Drop two TdxMemData components onto a form. Name the first mdCountries, the second mdIntFriends.

 

2. Double click on the mdCountries component to call the MemData Field Editor window and press the Add… button. The New Field form should now be active:

 

  To add a new field you must fill:

l Field Name; l Type; l Size (for string fields only);

Page 2 of 98

l Field Type (Default data); l Lookup definition for lookup fields only.

  3. Create two fields: ID (Integer) and Name (String, char(50)), and close the MemData Field Editor window.   4. Double click on the mdIntFriends component and add its fields:   ID (Integer), FirstName (String char(25)), LastName (String char(25)), NickName (String char(10)), Email (String char(80)), birthday ((Date), interests (String char(250)) and CountryID (Integer).   5. Now we have to add the lookup field to bind mdIntFreinds.CountryID to mdCountries.ID.   Name it CountryName, type ftString, Size 50, field type – lookup and lookup definition: Key Field – CountryID, DataSet - mdCountries, Lookup Field - ID and Result Field – Name.  

  Now we have a lookup field. In both the Borland DBGrid and ExpressQuantumGrid™ by Developer Express Inc., this will be represented as a lookup combo (in the ExpressQuantumGrid, it is represented as an incremental lookup combo).   6. Now we have to set correct ID field values for our TdxMemData components. Write the following event handler for onAfterInsert:   procedure TForm1.dmCountriesAfterInsert(DataSet: TDataSet); begin DataSet.FindField('ID').AsInteger := DataSet.FindField('recid').AsInteger; end;   You can use this code for both components: dmCountries and dmIntFriends. ‘RECID’ is the field that is created for each TdxMemData. You can see it at design time in the Object Inspector or TdxMemData fields editor.   It is a unique, Auto Incremental field. In this demo, we use it as an index field to get the next value for our ID fields. It can be used as a KeyField in the dxDBGrid control.   7. Now we have to write code to save and restore data in a text file. Here it is:   // Loads the data on the form OnCreate event, checks if the file exists procedure TForm1.FormCreate(Sender: TObject); var

Page 3 of 98

FileName : string; begin FileName := ExtractFileDir(Application.ExeName) + '\countries.txt'; if FileExists(FileName) then mdCountries.LoadFromTextFile(FileName); FileName := ExtractFileDir(Application.ExeName) + '\intfriends.txt'; if FileExists(FileName) then mdIntFriends.LoadFromTextFile(FileName); end;   // Saves the data on the form destroy event procedure TForm1.FormDestroy(Sender: TObject); begin mdCountries.SaveToTextFile(ExtractFileDir(Application.ExeName) + '\countries.txt'); mdIntFriends.SaveToTextFile(ExtractFileDir(Application.ExeName) + '\intfriends.txt'); end;   8. Now drop two TDataSources and name them dsCountries and dsIntFriends, then link them with your TdxMemData

components.   9. Set Active to True for both TdxMemData components. The final step is to link your data sources with individual data controls.   And that's all you need to do!

Page 4 of 98

Known Issues and Important Changes List Getting Started All entries in the following list are grouped by Builds, in reverse order.   Build 37 An intermediate TdxCustomMemData class has been introduced. It implements all the functionality of its descendant TdxMemData class, which now simply publishes some properties and events of its ancestor classes. As a result, the TdxMemField.DataSet, TdxMemFields.DataSet, and TdxMemIndex.MemData properties are now of the TdxCustomMemData type.

Page 5 of 98

dxmdaset Unit Classes TdxCustomMemData TdxMemData TdxMemField TdxMemFields TdxMemIndex TdxMemIndexes

Page 6 of 98

How to Add Different Types of Data to ExpressMemData This article illustrates the quickest way to populate ExpressMemData fields. You can perform this by directly accessing fields.  

  The following image demonstrates the code execution result:

  // Delphi // ... type const FileName = 'MemData.txt'; // ... procedure <TForm1>.FormCreate(Sender: TObject); begin if FileExists(FileName) then mData.LoadFromTextFile(FileName); end;   procedure <TForm1>.FormDestroy(Sender: TObject); begin mData.SaveToTextFile(FileName); end;   procedure <TForm1>.<Button1>Click(Sender: TObject); var I: Integer; ADate: TDate; S, AFName, ALName: string; begin I := 1; S := '12/9/1953'; ADate := StrToDate(S); AFName := 'John'; ALName := 'Malkovich'; // ExpressMemData must be active mData.Active := True; // Disable the data controls to prevent flickering mData.DisableControls; try begin mData.Append; mData.FieldValues['ID'] := I; mData.FieldValues['FName'] := AFName; mData.FieldValues['LName'] := ALName; mData.FieldValues['DOB'] := ADate; mData.Post; end; finally // Enable the data controls mData.EnableControls; end;

Field Name Field Type  

ID TIntegerField

FName TStringField LName TStringField DOB TDateField

Page 7 of 98

end;   // C++ Builder // ... const UnicodeString FileName = "MemData.txt"; // ... void __fastcall <TForm1>::FormCreate(TObject *Sender) { if (FileExists(FileName)) mData->LoadFromTextFile(FileName); } //---------------------------------------------------------------------   void __fastcall <TForm1>::FormDestroy(TObject *Sender) { mData->SaveToTextFile(FileName); } //--------------------------------------------------------------------- void __fastcall <TForm1>::<Button1>Click(TObject *Sender) { const int I = 1; const UnicodeString AFName = "John"; const UnicodeString ALName = "Malkovich"; const UnicodeString S = "12/9/1953"; const TDate ADate = StrToDate(S); // ExpressMemData must be active mData->Active = true; // Disable the data controls to prevent flickering mData->DisableControls(); try { mData->Append(); mData->FieldValues["ID"] = I; mData->FieldValues["FName"] = AFName; mData->FieldValues["LName"] = ALName; mData->FieldValues["DOB"] = ADate; mData->Post(); } __finally { // Enable the data controls mData->EnableControls(); } } //---------------------------------------------------------------------

Page 8 of 98

How to Populate an ExpressMemData Table from Another ExpressMemData or Any Other TDataSet Descendant This article demonstrates how to populate an ExpressMemData table, with another ExpressMemData or any other TDataSet descendant. To accomplish this, you should use the LoadFromDataSet method. Here is the code:   // Delphi dxMemData1.Close; dxMemData1.LoadFromDataSet(dxMemData2);   // C++ Builder dxMemData1->Close(); dxMemData1->LoadFromDataSet(dxMemData2);   At design time, you can use the 'Assign Data From' item in the TdxMemData component’s context menu, to choose any available TDataSet descendant as a source for this TdxMemData component.

Page 9 of 98

How to Populate ExpressMemData via Direct Memory Access This example demonstrates how to append a new record that contains two fields (an integer and a string) to the ExpressMemData component.   // Delphi var I: Integer; // ... I := 9; dxMemData1.Append; // RecId field dxMemData1.Fields[0].Value := I; // integer field dxMemData1.Fields[1].Value := I; // string field dxMemData1.Fields[2].Value := 'New value'; dxMemData1.Post; dxMemData1.Last;   // C++ Builder int i = 9; // ... dxMemData1->Append(); // RecId field dxMemData1->Fields[0]->Value = i; // integer field dxMemData1->Fields[1]->Value = i; // string field dxMemData1->Fields[2]->Value = "New value"; dxMemData1->Post(); dxMemData1->Last();

Page 10 of 98

TdxMemData Hierarchy Properties Methods Events Represents the TdxMemData component.   Unit dxmdaset   TdxMemData = class(TdxCustomMemData)   Description The TdxMemData class does not introduce any new functionality. It simply publishes properties derived from the base TdxCustomMemData class. Refer to this class description for details on available members.

Page 11 of 98

TdxCustomMemData Hierarchy Properties Methods Events See Also The TdxCustomMemData class is directly inherited from TDataSet.   Unit dxmdaset   TdxCustomMemData = class(TDataSet);   Description TdxCustomMemData works directly with memory and allows you to work with small amounts of data with lightening fast speeds.   The TdxCustomMemData supports:

l Calculated and lookup fields l Sorting by any field, including calculated and lookup fields l Bookmarks (multiple select for grid controls) l Locate, lookup methods

Page 12 of 98

TdxMemField Hierarchy Properties Methods See Also The TdxMemField is the object used by the ExpressMemData component to store specific memory field definitions.   Unit dxmdaset   TdxMemField = class(TCollectionItem);   Description The TdxMemField object allows you to get access to the memory field definition. Each of ExpressMemData's memory fields is a list of pointers to field values.

Page 13 of 98

TdxMemFields Hierarchy Properties Methods TdxMemFields is a collection of TdxMemField objects used by the ExpressMemData component to store the memory field definitions.   Unit dxmdaset   TdxMemFields = class(TCollection);   Description TdxMemFields is a container for ExpressMemData's memory fields. It is a collection of lists, where each item is a TdxMemField object.

Page 14 of 98

TdxMemIndex Hierarchy Properties Methods TdxMemIndex is the object used by the ExpressMemData component to store a specific index for a memory field.   Unit dxmdaset   TdxMemIndex = class(TCollectionItem);   Description With the ExpressMemData, a user can index data by one field similar to indexing applied to Paradox tables. The TdxMemIndex object allows you to work with a single index.

Page 15 of 98

TdxMemIndexes Hierarchy Methods TdxMemIndexes is a collection of TdxMemIndex objects used by the ExpressMemData component to maintain indexes for memory field definitions.   Unit dxmdaset   TdxMemIndexes = class(TCollection);   Description With ExpressMemData, a user can index data by one field similar to indexing applied to Paradox tables. The TdxMemIndexes object maintains a list of these indexes. Each item of this list represents an independent index against which a sort order can be based.

Page 16 of 98

Direct Access example This example demonstrates how to obtain access to each value of the ExpressMemData component.   // Delphi uses

..., dxCore; type TRecordBuffer = ^Byte; 

procedure TForm1.Button1Click(Sender: TObject); var

I: Integer; ABuffer: TRecordBuffer; AIntegerValue: Integer; AStringValue: AnsiString; begin with dxMemData do for I := 0 to RecordCount - 1 do begin

// Accessing AnsiString field by its index (AnsiStringFieldIndex)

ABuffer := Data.Items[AnsiStringFieldIndex].Values[I]; AStringValue := PAnsiChar(ABuffer); // Accessing Integer field by its index (IntegerFieldIndex)

ABuffer := Data.Items[IntegerFieldIndex].Values[I]; AIntegerValue := PInteger(ABuffer) ;̂ end; end;

Page 17 of 98

TdxMemData.MoveCurRecordTo example This example demonstrates how to move a specific record.   // Moves a specified record to the beginning of the ExpressMemData

procedure TForm1.Button3Click(Sender: TObject); begin dxMemData1.DisableControls; 

// Move record

dxMemData1.MoveCurRecordTo(1); 

dxMemData1.EnableControls; 

// Go to the first record

dxMemData1.First; 

end;

Page 18 of 98

TdxMemData.SaveToStream, TdxMemData.LoadFromStream example This example demonstrates how to save and load the ExpressMemData component using a stream.   // Copies data from one ExpressMemData component to another

procedure TForm1.Button1Click(Sender: TObject); var fMem : TMemoryStream; 

begin fMem := TMemoryStream.Create; 

// Saves the 1st ExpressMemData data to a stream

dxMemData1.SaveToStream(fMem); 

// Sets the Stream position

fMem.Position := 0; 

// Populates the 2nd ExpressMemData data from the stream, containing data from the 1st ExpressMemData

dxMemData2.LoadFromStream(fMem); 

fMem.Free; 

end;

Page 19 of 98

TdxMemData.DelimiterChar, TdxMemData.SaveToTextFile, TdxMemData.LoadFromTextFile example This example demonstrates how to save and load the ExpressMemData component using a text file.   // Saves data to a text file with commas as column separators

procedure TForm1.Button1Click(Sender: TObject); begin

// Defines commas as column separators

dxMemData1.DelimiterChar := ',';

dxMemData1.SaveToTextFile(ExtractFileDir(Application.ExeName) + 'mdata.txt');

end;  

// Loads data from a text file with commas as column separators

procedure TForm1.Button2Click (Sender: TObject); begin with dxMemData1 do begin DisableControls; 

DelimiterChar := ',';

// Define comma as column separator

LoadFromTextFile(ExtractFileDir(Application.ExeName) + 'mdata.txt');

EnableControls; 

end; end;

Page 20 of 98

TdxCustomMemData.AddFieldsFromDataSet TdxCustomMemData Automatically re-creates missing fields based on field information retrieved from a specified dataset.   procedure AddFieldsFromDataSet(ADataSet: TDataSet; AOwner: TComponent = nil);

  Description Call this method to retrieve field information (existing fields or their definitions) from the dataset specified by the ADataSet parameter and create corresponding fields within a TDataSet descendant passed as the AOwner parameter. If nil is passed as AOwner, fields are created within the current ExpressMemData component.   This method first checks whether a field type is supported by the ExpressMemData component and then creates only fields that are missing (based on field names in ADataSet and AOwner). All the main data type-specific property values are also copied from the source dataset fields.   The CreateFieldsFromDataSet method calls the AddFieldsFromDataSet method internally to create necessary fields.   Note: If ADataSet contains a field with the name associated with the ‘RecId’ field (see RecIdField), this field will not be created in AOwner. To overcome this, change the default name of the field via the RecIdField.FieldName property before the AddFieldsFromDataSet or CreateFieldsFromDataSet method is called.

Page 21 of 98

TdxCustomMemData.CopyFromDataSet TdxCustomMemData Makes a copy of a specified dataset.   procedure CopyFromDataSet(DataSet: TDataSet);

  Description Call this method to duplicate the structure and data of the specified DataSet within the current ExpressMemData component. To accomplish this, the CopyFromDataSet method calls CreateFieldsFromDataSet and then LoadFromDataSet.   Note: Before copying DataSet contents the current ExpressMemData component is cleared.

Page 22 of 98

TdxCustomMemData.CreateFieldsFromBinaryFile TdxCustomMemData See Also Automatically creates fields by reading field definitions from a specified binary file.   procedure CreateFieldsFromBinaryFile(const AFileName: string);

  Description Call this method to retrieve all fields from a binary file specified via the AFileName parameter. This method checks the specified file for supported field types and then adds supported fields to the current ExpressMemData. To create CreateFieldsFromBinaryFile-compatible binary files, save ExpressMemData data via the SaveToBinaryFile method call.   At design time, you can use the functionality provided by the ExpressMemData Persistent Editor to create fields from a previously saved binary file (via the Get Fields… button).

Page 23 of 98

TdxCustomMemData.CreateFieldsFromDataSet TdxCustomMemData See Also Automatically creates fields based on fields from a specified dataset.   procedure CreateFieldsFromDataSet(DataSet : TDataSet, AOwner: TComponent = nil);

  Description This method first removes all the fields created within the current ExpressMemData component and then calls the AddFieldsFromDataSet method, passing parameters to it in order to create fields based on DataSet.

Page 24 of 98

TdxCustomMemData.CreateFieldsFromStream TdxCustomMemData See Also Automatically creates fields from a specified stream.   procedure CreateFieldsFromStream(Stream : TStream);

  Description Call the CreateFieldsFromStream method to retrieve all fields from a stream specified by the Stream parameter. This method checks whether a field type is supported by the ExpressMemData and then adds supported fields.   Note: A stream must contain data in ExpressMemData internal format (For example, data written to a stream by

another ExpressMemData using the SaveToStream method).

Page 25 of 98

TdxCustomMemData.Data TdxCustomMemData Example Returns the ExpressMemData's fields definitions.   property Data : TdxMemFields;   Description Use the Data property to get access to the ExpressMemData's fields definitions.   ReadOnly Property

Page 26 of 98

TdxCustomMemData.DelimiterChar TdxCustomMemData Example Specifies the column separator character.   property DelimiterChar : Char;   Description The character specified by this property is used when storing or restoring data using the SaveToTextFile, SaveToStrings, LoadFromTextFile, and LoadFromStrings methods.   The default value of the DelimiterChar property is the Tab character (VK_TAB).

Page 27 of 98

TdxCustomMemData.FillBookMarks TdxCustomMemData Fills ExpressMemData bookmarks.   procedure FillBookMarks;   Description Call this method only when you insert data using direct access without standard DataSet methods like Append or Insert.

Page 28 of 98

TdxCustomMemData.Filter TdxCustomMemData Specifies the text of the current filter for a dataset.   property Filter: string;

  Description The property value is ignored by the ExpressMemData component – to specify the filter (i.e., filter dataset records), use any of the following methods:

l Set the ProgrammedFilter property to False, handle the OnFilterRecord event, and pass required values as the Accept event parameter;

l Set the ProgrammedFilter property to True and populate a list of filtered records accessible using the FilterList property.

  Once you have specified the filter, set the Filtered property to True.

Page 29 of 98

TdxCustomMemData.FilterList TdxCustomMemData Determines the list of filtered records.   property FilterList : TList;

  Description This property is used to maintain a list of filtered records when the ProgrammedFilter property is set to True. Only these records will be displayed in a filtered dataset. If the ProgrammedFilter property is set to False, the list is generated automatically with the help of the OnFilterRecord event.   The following code shows how to populate the FilterList list property.   // Delphi with <dxMemData1> do begin

ProgrammedFilter := True; First; while not Eof do begin if <your condition here> then

FilterList.Add(CurRec + 1); Next; end;

Filtered := True; end;

Page 30 of 98

TdxCustomMemData.GetRecNoByFieldValue TdxCustomMemData The GetRecNoByFieldValue method returns a record number by a specific field value.   function GetRecNoByFieldValue(Value: Variant; FieldName: String): Integer; virtual;   Description Call the GetRecNoByFieldValue method to obtain a specific RecNo. Use the Value and FieldName parameters to specify the required RecNo. If an applicable record is not found, the GetRecNoByFieldValue returns -1. If there is more than one record with a specific value, the RecNo of the first record is returned.

Page 31 of 98

TdxCustomMemData.GetValueCount TdxCustomMemData Determines the number of records that contain a specified field value.   function GetValueCount(FieldName: String; Value: Variant): Integer;

  Description Call the GetValueCount method to determine how many ExpressMemData records contain the value specified by the Value parameter in the field specified by the FieldName parameter.

Page 32 of 98

TdxCustomMemData.Indexes TdxCustomMemData Determines indexes for a specific ExpressMemData control.   property Indexes: TdxMemIndexes;

  Description With ExpressMemData, a user can index data by one field similar to indexing using Paradox tables. The Index property is used to work with these indexes via a TdxMemIndexes object.

Page 33 of 98

TdxCustomMemData.IsLoading TdxCustomMemData Indicates whether the data loading process is active.   property IsLoading : Boolean;   Description Use this property to know whether the ExpressMemData is loading data. You can also employ this property when using your own methods of data loading.

Page 34 of 98

TdxCustomMemData.LoadFromBinaryFile TdxCustomMemData See also Loads data from a binary file.   procedure LoadFromBinaryFile(FileName : string); dynamic;   Description Use this method to load data from a binary file specified by the FileName parameter.   Note: A file specified by the FileName parameter must contain data in the ExpressMemData internal format (For

example, data written to a file by another ExpressMemData using the SaveToBinaryFile method).   Example // Load data from a binary file

procedure TForm1.Button1Click (Sender: TObject); begin with dxMemData1 do begin DisableControls;

// Define comma as column separator

LoadFromBinaryFile(ExtractFileDir(Application.ExeName) + 'mdata.bin');

EnableControls; 

end; end;

  At design time, you can use the functionality provided by the ExpressMemData Persistent Editor to save/load data from a binary file (via the Save… and Load… buttons).

Page 35 of 98

TdxCustomMemData.LoadFromDataSet TdxCustomMemData See also Loads data from a specified dataset.   procedure LoadFromDataSet(DataSet: TDataSet);

  Description Call this method to load data from a dataset specified by the DataSet parameter.   Note: When retrieving data from a dataset, make certain that this dataset contains the fields supported by

ExpressMemData.

Page 36 of 98

TdxCustomMemData.LoadFromStream TdxCustomMemData Example See also Loads data from a stream.   procedure LoadFromStream(Stream : TStream); dynamic;   Description Call LoadFromStream to populate the ExpressMemData with data from a stream. The Stream parameter specifies the name of a stream from which to read data.   Note: A stream must contain data in ExpressMemData internal format (For example, data written to a stream by

another ExpressMemData using the SaveToStream method).

Page 37 of 98

TdxCustomMemData.LoadFromStrings TdxCustomMemData See also Loads data from a specified string list.   procedure LoadFromStrings(AStrings: TStrings); dynamic;   Description Call this method to populate the ExpressMemData component with data from a string list referenced by the AStrings parameter. The string list must contain data in the format that is produced by the SaveToStrings method. Refer to the description of the SaveToStrings method to learn about its specifics.   The LoadFromStrings method is called internally by the LoadFromTextFile method, which loads data from a file to a string list using the list’s LoadFromFile method and then calls LoadFromStrings to load the data to the ExpressMemData component.

Page 38 of 98

TdxCustomMemData.LoadFromTextFile TdxCustomMemData Example See also Loads data from a specified text file.   procedure LoadFromTextFile(FileName: string); dynamic;

  Description Call this method to populate the ExpressMemData component with data from a text file specified by the FileName parameter. The file must contain data in the format produced by the SaveToTextFile method. Refer to the description of the SaveToTextFile method to learn about its specifics.   The LoadFromTextFile method calls the LoadFromStrings method internally to load data from a file to a string list using the list’s LoadFromFile method, and then calls LoadFromStrings to load the data to the ExpressMemData component.

Page 39 of 98

TdxCustomMemData.Locate TdxCustomMemData Searches the KeyValues values in the KeyFields fields.   function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; override;   Description The Locate method returns True if a record is found that matches the KeyFields and KeyValues search criteria. The KeyFields parameter specifies record fields where the KeyValues values will be searched; The KeyValues parameter specifies the values to be searched; The Options parameter specifies whether the search is case sensitive and whether the partial matching is available.

Page 40 of 98

TdxCustomMemData.MoveCurRecordTo TdxCustomMemData Example Moves the current record to a new position within the ExpressMemData.   procedure MoveCurRecordTo(Index : Integer);   Description Use this method if you wish to move the current active record to another position specified by the Index parameter. Note that you should pass 1 to move the record to the first position. Passing zero or negative values has no effect.

Page 41 of 98

TdxCustomMemData.ProgrammedFilter TdxCustomMemData Determines the manner in which the ExpressMemData is filtered.   property ProgrammedFilter : Boolean;

  Description This property is used for faster filtering. If this property is set to True, the OnFilterRecord event does not fire so you can select the records for the list of filtered records provided by the FilterList property. Otherwise, the list is generated automatically with the help of the OnFilterRecord event.

Page 42 of 98

TdxCustomMemData.ReadOnly TdxCustomMemData Specifies whether the ExpressMemData is read-only.   property ReadOnly : Boolean;   Description Use the ReadOnly property to prevent users from updating, inserting, or deleting data within the ExpressMemData component. By default, the ReadOnly property is False.

Page 43 of 98

TdxCustomMemData.RecIdField TdxCustomMemData Returns a pointer to the 'RecId' field of the ExpressMemData component.   property RecIdField : TField;   Description The 'RecId' field is invisible and is created automatically during the creation of the ExpressMemData component. The RecIdField is a unique field.   Note: If you do not have a unique field and wish to use the grouping capabilities of the ExpressQuantumGrid™, use the

'RecId' field as a KeyField property of a lookup grid column.   Example // Set a unique field after the insert operation procedure TForm1.dxMemData1AfterInsert(DataSet: TDataSet); begin

DataSet.FindField('id').AsInteger := DataSet.FindField('recid').AsInteger; end;

  Note: Use the RecIdField.FieldName property to modify the default name of the ‘RecId’ field to avoid conflicts when loading data or fields from another dataset via the CreateFieldsFromDataSet or AddFieldsFromDataSet method call.   ReadOnly Property

Page 44 of 98

TdxCustomMemData.SaveToBinaryFile TdxCustomMemData See also Saves data to a binary file.   procedure SaveToBinaryFile(FileName: string); dynamic;   Description Call this method if you want to save data to a binary file specified by the FileName parameter.   // Saves data to a binary file

procedure TForm1.Button1Click(Sender: TObject); begin dxMemData1.SaveToBinaryFile(ExtractFileDir(Application.ExeName) + 'mdata.bin');

end;

  After this, you can load data from this file via the LoadFromBinaryFile method call.   At design time, you can use the functionality provided by the ExpressMemData Persistent Editor to save/load data from a binary file (via the Save… and Load… buttons).

Page 45 of 98

TdxCustomMemData.SaveToStream TdxCustomMemData Example See also Saves data to a stream.   procedure SaveToStream(Stream: TStream); dynamic;   Description Call this method to write the ExpressMemData's data to a stream. The Stream parameter specifies the existing stream.

Page 46 of 98

TdxCustomMemData.SaveToStrings TdxCustomMemData See also Saves data to a specified string list.   procedure SaveToStrings(AStrings: TStrings); dynamic;   Description Call this method to store the ExpressMemData component’s data to a string list referenced by the AStrings parameter. The first string in the list enumerates field names, while all other strings contain string representations of the corresponding field values. The SaveToStrings method uses the DelimiterChar to separate field entries in each output string.   The SaveToTextFile method calls the SaveToStrings method internally to store data to a string list and then calls the list’s SaveToFile method to store the data to a file.   Note: Since the SaveToStrings method’s output depends upon current regional settings, you are not guaranteed that all data will be loaded properly at a later point in time. If regional settings differ from the original settings with which the string list was created, loading errors may occur. To make certain that your data is persisted regardless of regional settings, use the SaveToBinaryFile, SaveToStream, LoadFromBinaryFile, and LoadFromStream methods instead.

Page 47 of 98

TdxCustomMemData.SaveToTextFile TdxCustomMemData Example See also Saves data to a specified text file.   procedure SaveToTextFile(FileName: string); dynamic;   Description Pass the target file’s name as the FileName parameter. The method calls the SaveToStrings method internally to store the ExpressMemData component’s data to a string list and then stores the list’s data to a specified file via the list’s SaveToFile method call. Refer to the description of the SaveToStrings method to learn about its specifics.   Note: Since the SaveToStrings method’s output depends upon current regional settings, you are not guaranteed that all data will be loaded properly at a later point in time. If regional settings differ from the original settings with which the text file was created, loading errors may occur. To make certain that your data is persisted regardless of regional settings, use the SaveToBinaryFile, SaveToStream, LoadFromBinaryFile, and LoadFromStream methods instead.

Page 48 of 98

TdxCustomMemData.SetFilteredRecNo TdxCustomMemData Sets the active filtered record.   procedure SetFilteredRecNo(Value: Integer);

  Description Call this method to activate a record whose index, in the list of filtered records, is equal to the Value parameter value.

Page 49 of 98

TdxCustomMemData.SortedField TdxCustomMemData See also Specifies the name of the field by which the ExpressMemData component is sorted.   property SortedField : String;   Description Use the SortedField property to specify the field name by which the ExpressMemData is sorted. By default, the ExpressMemData sorts this field data in ascending order. To change the sort order, apply the SortOptions property. Additionally, using the SortOptions property, you can set case insensitive sorting.   Note: Sorting is not performed by calculated fields.

Page 50 of 98

TdxCustomMemData.SortOptions TdxCustomMemData See also Specifies the sort settings for the ExpressMemData component.   type TdxSortOption = (soDesc, soCaseInsensitive);  TdxSortOptions = set of TdxSortOption;

property SortOptions : TdxSortOptions;   Description The following values are available:  

  By default, all these options are inactive.

soDesc If active, ExpressMemData sorts in descending order, otherwise it sorts in ascending order.

soCaseInsensitive Determines whether sorting is case insensitive.

Page 51 of 98

TdxCustomMemData.SupportedFieldType TdxCustomMemData Determines whether a specific FieldType is supported by the ExpressMemData component.   function SupportedFieldType(AType: TFieldType): Boolean; virtual;   Description Use the SupportedFieldType to determinate whether a field type is supported by the ExpressMemData (As determined by the AType parameter). If a given field type is supported, the SupportedFieldType returns True; Otherwise - False.

Page 52 of 98

TdxCustomMemData.UpdateFilters TdxCustomMemData Updates ExpressMemData filters.   procedure UpdateFilters; virtual;   Description Call this method to update the ExpressMemData filters which can be defined in the OnFilterRecord event. Use this method when making changes to filter definitions.

Page 53 of 98

TdxMemFields.Add TdxMemFields See Also Adds a new field to the memory fields collection.   function Add(AField : TField) : TdxMemField;

  Description Call the Add method to add a new memory field specified by the AField parameter to the end of the available fields list. This method returns the newly created TdxMemField object.

Page 54 of 98

TdxMemFields.AddField TdxMemFields See Also Adds a new field to the memory fields collection.   procedure AddField(Field : TField);

  Description The AddField method is used internally to add a new memory field specified by the AField parameter. If this field is not in the list of available fields, it is added to the end of the list.

Page 55 of 98

TdxMemFields.Clear TdxMemFields See Also Deletes all memory fields from the TdxMemFields collection.   procedure Clear;

  Description The Clear method frees the memory used to store the memory fields list and all corresponding records.

Page 56 of 98

TdxMemFields.Count TdxMemFields See Also Indicates the number of memory fields in a TdxMemFields collection.   property Count : Integer;   Description Use the Count property to obtain the number of memory fields.   ReadOnly Property

Page 57 of 98

TdxMemFields.DataSet TdxMemFields Provides access to a corresponding ExpressMemData component.   property DataSet : TdxCustomMemData;   ReadOnly Property

Page 58 of 98

TdxMemFields.DeleteRecord TdxMemFields See Also Deletes a specific record.   procedure DeleteRecord(AIndex : Integer);

  Description Call the DeleteRecord method to delete a record specified by the AIndex parameter. The first record has an index of 0, the second record has an index of 1, etc. The last record has an index of Count-1.

Page 59 of 98

TdxMemFields.GetCount TdxMemFields See Also Returns the number of memory fields in a TdxMemFields collection.   function GetCount : Integer;

  Description The GetCount method is used internally to obtain the number of memory fields.

Page 60 of 98

TdxMemFields.IndexOf TdxMemFields Locates the MemField object in a MemFields array.   function IndexOf(Field : TField): TdxMemField;   Description Call the IndexOf to get the MemField specified by the Field parameter. If the required field is not found, IndexOf returns nil.

Page 61 of 98

TdxMemFields.InsertRecord TdxMemFields See Also Inserts a new record.   procedure InsertRecord(Buffer: Pointer; AIndex : Integer; Append: Boolean);

  Description Call the InsertRecord method to insert a new record into the ExpressMemData. The Buffer parameter contains a pointer to the inserted record. AIndex determines the index at which to insert this record. The first record has an index of 0, the second record has an index of 1 etc. The last record has an index of Count-1. The Append parameter determines whether to add or insert a new record. If this parameter is True, then a record is simply added to the end of all records; If False, it is inserted at the specified position and indexes of all subsequent records are recalculated.

Page 62 of 98

TdxMemFields.Items TdxMemFields Example Lists the MemField definitions that describe each memory field in the ExpressMemData component.   property Items[Index:Integer] : TdxMemField;   Description To access a specific MemField's definition specify the Index parameter. The Index parameter is in the range from 0 to Count - 1.   ReadOnly Property

Page 63 of 98

TdxMemFields.RecordCount TdxMemFields See Also Example Indicates the total number of records in a corresponding ExpressMemData.   property RecordCount : Integer;   Description The RecordCount property returns the total number of records in a corresponding ExpressMemData.   ReadOnly Property

Page 64 of 98

TdxMemFields.RemoveField TdxMemFields See Also Removes a field from the memory fields collection.   procedure RemoveField(Field : TField);

  Description Call the RemoveField method to delete a field specified by the Field parameter from the list of available memory fields in the TdxMemFields collection.

Page 65 of 98

TdxMemField.AddValue TdxMemField See Also Adds a new field definition to a TdxMemField object instance.   procedure AddValue(const Buffer : PChar);

  Description Call the AddValue method to add a new field definition to the end of the list of available field definitions for a specific field. The Buffer parameter determines the value to add. When added, the new value can be displayed.

Page 66 of 98

TdxMemField.DataSet TdxMemField Specifies a corresponding dataset.   property DataSet : TdxCustomMemData;   Description Use this property to get access to a corresponding ExpressMemData component.   ReadOnly Property

Page 67 of 98

TdxMemField.Field TdxMemField Specifies a corresponding field.   property Field : TField;   Description Use this property to get access to a corresponding field definition.   ReadOnly Property

Page 68 of 98

TdxMemField.HasValues TdxMemField Used internally by the SaveToStream and Locate methods. You might never need to use it directly.   property HasValues[Index:Integer]: Char;

Page 69 of 98

TdxMemField.Index TdxMemField See Also Specifies the field definition’s index number in the Fields property of a dataset.   property Index: Integer;

  Description Use the Index property to locate a field within a dataset. Change the value of the Index property to change the location of a field within a dataset. Changing the Index value affects the order in which fields are displayed in data grids, but not their position in the physical database tables.   Note: The field order can also be changed by dragging and dropping fields in the Fields editor at design time.

Page 70 of 98

TdxMemField.InsertValue TdxMemField See Also Inserts a new field definition to a TdxMemField object instance.   procedure InsertValue(AIndex : Integer; const Buffer : PChar);

  Description Call the InsertValue method to insert a new field definition to the list of available field definitions of a specific field. The AIndex parameter determines the position at which a new value is inserted. The Buffer parameter determines the value to add. When added a new value can be displayed.

Page 71 of 98

TdxMemField.MemFields TdxMemField Determines the corresponding TdxMemFields object.   property MemFields : TdxMemFields;   Description Use the MemFields property to get access to a TdxMemFields object, which contains the MemField.   ReadOnly Property

Page 72 of 98

TdxMemField.Values TdxMemField Example Determines the values of a MemField.   property Values[Index: Integer]: PChar;   Description Use the Values property to read values stored within the field. The value is read from the record whose index is specified by the Index parameter. Note that record indexes are zero-based. Passing a negative value or a value exceeding the last available index raises an exception.   ReadOnly property

Page 73 of 98

TdxMemIndexes.Add TdxMemIndexes Adds a new index to the collection of available indexes.   function Add: TdxMemIndex;

  Description Call the Add method to create a new item in the collection of indexes in the ExpressMemData.

Page 74 of 98

TdxMemIndexes.GetIndexByField TdxMemIndexes Returns a specific TdxMemIndex instance.   function GetIndexByField(AField: TField): TdxMemIndex;

  Description Since each memory field can contain only a single index, the GetIndexByField method allows you to locate a specific index that corresponds to the field specified by the AField parameter.

Page 75 of 98

TdxMemIndex.FieldName TdxMemIndex Determines the field name to be indexed.   property FieldName: string;

  Description Use the FieldName property to specify the index for ExpressMemData. If this property contains a valid field name, then that index determines the sort order of records.   Note: Only one field name can be specified in each index.

Page 76 of 98

TdxMemIndex.GotoNearest TdxMemIndex Locates a record with a specific value in ExpressMemData.   function GotoNearest(const Buffer : PChar; var Index : Integer) : Boolean;

  Description The GotoNearest method is called to locate a record that contains the value specified by the Buffer parameter in the current ExpressMemData instance. The Index parameter determines the index of the resultant record. This method returns True if the search was successful; Otherwise False.

Page 77 of 98

TdxMemIndex.MemData TdxMemIndex Provides access to an ExpressMemData instance to which the current index is applied.   property MemData: TdxCustomMemData;

  ReadOnly Property

Page 78 of 98

TdxMemIndex.Prepare TdxMemIndex Prepares an ExpressMemData instance to use the current index.   procedure Prepare;

  Description Since ExpressMemData allows you to create several indexes, this method rebuilds an ExpressMemData instance to apply the new index.

Page 79 of 98

TdxCustomMemData events TdxCustomMemData Legend   Derived from TDataSet   AfterCancel   AfterClose   AfterDelete   AfterEdit   AfterInsert   AfterOpen   AfterPost   AfterScroll   BeforeCancel   BeforeClose   BeforeDelete   BeforeEdit   BeforeInsert   BeforeOpen   BeforePost   BeforeScroll   OnCalcFields   OnDeleteError   OnEditError   OnFilterRecord   OnPostError

Page 80 of 98

TdxMemData events TdxMemData Legend   Derived from TDataSet   AfterCancel   AfterClose   AfterDelete   AfterEdit   AfterInsert   AfterOpen   AfterPost   AfterScroll   BeforeCancel   BeforeClose   BeforeDelete   BeforeEdit   BeforeInsert   BeforeOpen   BeforePost   BeforeScroll   OnCalcFields   OnDeleteError   OnEditError   OnFilterRecord   OnPostError

Page 81 of 98

TdxCustomMemData methods TdxCustomMemData Legend   In TdxCustomMemData   AddFieldsFromDataSet   CopyFromDataSet   CreateFieldsFromBinaryFile   CreateFieldsFromDataSet   CreateFieldsFromStream   FillBookMarks   GetRecNoByFieldValue   GetValueCount   LoadFromDataSet   LoadFromBinaryFile   LoadFromStream   LoadFromStrings   LoadFromTextFile   Locate   MoveCurRecordTo   SaveToBinaryFile   SaveToStream   SaveToStrings   SaveToTextFile   SetFilteredRecNo   SupportedFieldType   UpdateFilters

Page 82 of 98

TdxMemData methods TdxMemData Legend   Derived from TdxCustomMemData   AddFieldsFromDataSet   CopyFromDataSet   CreateFieldsFromBinaryFile   CreateFieldsFromDataSet   CreateFieldsFromStream   FillBookMarks   GetRecNoByFieldValue   GetValueCount   LoadFromDataSet   LoadFromBinaryFile   LoadFromStream   LoadFromStrings   LoadFromTextFile   Locate   MoveCurRecordTo   SaveToBinaryFile   SaveToStream   SaveToStrings   SaveToTextFile   SetFilteredRecNo   SupportedFieldType   UpdateFilters

Page 83 of 98

TdxMemField methods TdxMemField Legend   In TdxMemField   AddValue   InsertValue

Page 84 of 98

TdxMemFields methods TdxMemFields Legend   In TdxMemFields   Add   AddField   Clear   DeleteRecord   GetCount   IndexOf   InsertRecord   RemoveField

Page 85 of 98

TdxMemIndex methods TdxMemIndex Legend   In TdxMemIndex   GotoNearest   Prepare

Page 86 of 98

TdxMemIndexes methods TdxMemIndexes Legend   In TdxMemIndex   Add   GetIndexByField

Page 87 of 98

TdxCustomMemData properties TdxCustomMemData Legend   In TdxCustomMemData    Data   DelimiterChar   Filter   FilterList   Indexes   IsLoading   ProgrammedFilter    RecIdField   ReadOnly   SortedField   SortOptions   Derived from TDataSet   Active   Filter

Page 88 of 98

TdxMemData properties TdxMemData Legend   Derived from TdxCustomMemData    Data   DelimiterChar   FilterList   Indexes   IsLoading   ProgrammedFilter    RecIdField   ReadOnly   SortedField   SortOptions   Derived from TDataSet   Active   Filter

Page 89 of 98

TdxMemField properties TdxMemField Legend   In TdxMemField    DataSet    Field   HasValues    Index    MemFields    Values

Page 90 of 98

TdxMemFields properties TdxMemFields Legend   In TdxMemFields    Count    DataSet    Items    RecordCount

Page 91 of 98

TdxMemIndex properties TdxMemIndex Legend   In TdxMemIndex   FieldName    MemData

Page 92 of 98

Hierarchy   TDataSet |  TdxCustomMemData

Page 93 of 98

Hierarchy   TDataSet |  TdxCustomMemData |  TdxMemData

Page 94 of 98

Hierarchy   TCollectionItem |  TdxMemField

Page 95 of 98

Hierarchy   TCollection |  TdxMemFields

Page 96 of 98

Hierarchy   TCollection |  TdxMemIndexes

Page 97 of 98

Hierarchy   TCollectionItem |  TdxMemIndex

Page 98 of 98