You can create a memory table using MemoryTableBuilder object to define properties. Once defined, a Memory Table object is created by calling the CreateTable method.
Using Memory Table Builder Object
The type of data stored in the field affects the disk storage each field occupies. See Table Field Types for field types available.
MemoryTableBuilder object has the following methods to allow definition and manipulation of memory table properties:
Method |
Description |
|---|---|
Add a new field to the table definition. |
|
Add a new index to the table definition. |
|
Clear all fields and index definitions. |
|
Clear all field definitions. |
|
Clear all index definitions. |
|
Copy the field and index definitions from another table. |
|
Copy a field from another table. |
|
Create a new memory table. |
|
Return the value of a property or MaxBasic variable. |
|
PropertyType |
Return the type of the property. |
SetPropertyValue |
Set the value of a property or MaxBasic variable. |
All fields in the MemoryTableBuilder object can be accessed as an object, and properties can be modified. Additional field properties are accessible via the AddField method. This also allows field properties to be modified using the Clone method to provide a set of fields for MemoryTableBuilder. Properties available on each field are:
Property |
Type |
Description |
|---|---|---|
Alignment |
Number [Integer] |
Alignment to use for a grid or report displaying this field. |
DisplayLabel |
String |
Field caption to use for a grid or report displaying this field. |
DisplayWidth |
Number [Integer] |
Width in characters for a grid or report field displaying this field. |
FieldName |
String |
Name of the field. Must be a valid MaxBasic identifier (Read Only). |
Format |
String |
Format for numeric fields. This allows you to format numeric fields. For example, "0" will display the numeric field without formatting or decimals; "0,000.00" will display the field with comma thousand breaks and two decimal places. |
FormatMode |
Number [Integer] |
0 = Default. 1 = Zero to Null (i.e. Blank Zero if reporting / saving to file). 2 = Null to Zero. |
Group |
Number [Integer] |
Group number for field when reporting. |
Index |
Number [Integer] |
What number field is this. Ranges from 0 to number of fields - 1. |
ReadOnly |
Boolean |
When False, the field is editable. |
Required |
Boolean |
When False, the field is optional. |
Size |
Number [Integer] |
Maximum size for string fields (ReadOnly). |
Total |
Boolean |
Total this field on reports (only valid for numeric fields). |
Value |
Variant |
Value stored in the field. |
Visible |
Boolean |
When True, the fields is visible in grids and reports. |
MemoryTableBuilder Object Example
Dim Builder as ObjectBuilder = CreateObject("Accredo.MemoryTableBuilder")Dim NewField as ObjectNewField = Builder.AddField("Customercode", "Customer code")NewField.Required = TrueNewField = Builder.AddField("TotalAmount", "Amount")NewField.FormatMode = 1NewField = Builder.AddField("AnotherAmount", "Amount")NewField = Builder.AddField("CurrencyCode","CO Currency Code")NewField = Builder.AddField("Debit", "FX Amount")NewField.CurrencyCodeField = "CurrencyCode"
Builder.AddIndex("code", "Customercode", True)Dim Table as ObjectTable = Builder.CreateTable
'You can generate documentation for the table using the DocumentObject function as shown:DocumentObject(Table)
' Field properties can also be changed after tables have been created' Field properties can be directly referenced by field name or by field index (0 based)Table.Fields.Item("Debit").DisplayLabel = "Debit Amount"
Table.Fields.Item("Debit").Format = "0.00"Table.Fields.Item(0).DisplayLabel = "Customer"
Memory Table Documentation Example
See Example Memory Table Documentation to view the documentation generated. The fields defined in the example code appear as properties on the object, and the index appears as a value that can be assigned to the IndexName property.