#7 Components - TRestructure
Contents
This is a component written to help you restructure your tables in a very straightforward and efficient way. The component is a wrapper around BDE's DbiDoRestructure function. In fact, after many hours of headaches during the beta test phase, we have discovered that DbiDoRestructure has a bug - the headache stopped immediately.
Now it's very easy to restructure a table, for example:
Restructure1.DatabaseName := 'TestAlias';
Restructure1.TableName := 'TestTable.DB';
Restructure1.Field.Name := 'TestField';
Restructure1.Field.FieldType := pxAlpha;
Restructure1.Field.Length := 25;
Restructure1.ValCheck.Required := True;
Restructure1.PackTable := True;
Restructure1.InsertField(2, True);
Restructure1.Apply;
The above example will insert TestField as the second field in TestTable, and assign it a Required validity check. The table will also be packed in the process of restructuring. Have a look at the DEMO source code (included in this zip) for more examples on component usage.
Properties, methods and events
TRestructure
Properties:
DatabaseName
|
The database name. It can be existing alias,
or a directory.
|
||
+Field
|
|||
FieldType | Field type. For Paradox tables, use the types with prefix 'px', and for dBase tables prefix 'db'. | ||
Length | Specifies the field length (if applicable). | ||
Name | The field name. | ||
Precision | Field precision - only for dBase tables - specifies number of digits in the fractal part of the field. | ||
PackTable
|
A
Boolean value specifying whether to pack the table when applying changes.
If there are no pending changes, and this property is TRUE, the table
is packed.
|
||
TableName
|
The
table name. Must exist in the database specified in DatabaseName.
|
||
+ValCheck
|
|||
DefaultValue | Specifies default value for the field. | ||
LookupAccess | Two values can be entered: laFillNoHelp and laHelpAndFill. Ignored if LookupTableName is empty string. | ||
LookupDatabaseName | The database name of the lookup table. It can be existing alias, or a directory. | ||
LookupTableName | The lookup table name. Must exist in the database specified in LookupDatabaseName. | ||
LookupType | Two values can be entered: ltCurrentField and ltCorresponding. Ignored if LookupTableName is empty string. | ||
MaximumValue | Specifies maximum value for the field. | ||
MinimumValue | Specifies minimum value for the field. | ||
Picture | Specifies picture string for field input. | ||
Required | Specifies whether the field is required. |
Methods:
procedure GetFieldDesc(Position: Integer) | Fills all the field and validity check properties with the values from the actual table. Look at the DEMO source. | |
function FieldByName(FldName: String): Integer | Returns the field number, based on field name. | |
procedure AddField(lAddValChecks: Boolean) | Adds a field to the end of field order and adds validity check for that field (if lAddValChecks is TRUE). | |
procedure InsertField(Position: Integer; lAddValChecks: Boolean) | Inserts a field at a specified Position, and optionally adds a validity check for that field. | |
Procedure MoveField(OldPos, NewPos: Integer) | Moves a field from OldPos to NewPos position. | |
Procedure DropField(Position: Integer) | Deletes (removes) a field. | |
Procedure ChangeField(Position: Integer; lChangeValChecks: Boolean) | Changes any (or all) field properties, and/or validity checks. | |
Function HasValChecks(FldName: String) | Checks whether a field has any validity checks associated. | |
Procedure AddValCheck(FldName: String) | Adds a validity check (specified in ValCheck property) to a field. | |
Procedure ChangeValCheck(FldName: String) | Changes validity check. | |
Procedure DropValCheck(FldName: String) | Removes validity check from a field. | |
Procedure Apply | Applies all pending changes to table structure. | |
Procedure Cancel | Cancels all pending changes to table structure. |
Events:
OnFieldInappropriate | This event triggers each time you try to add or change field type that is not appropriate for the used table level. |
Start Delphi, open RestructurePack.dpk, compile and close it. Open DclRestructurePack.dpk, compile, install and close it.
If Delphi complains about not being able to find any .dcu, .dpl, or .bpl, simply copy the file that Delphi is looking for to "C:\Windows\System".
July 12, 2000. | 1.20 | First public release. |
August 29, 2000. | 1.24 |
Bugs corrected:
All these bugs were discovered by Mr. Fabio Lindner. Many thanks. |
The next release will allow you to add, change or delete referential integrity constraints, table passwords and more. We are planning to release the next version by the end of September 2000. Initially, the next version was scheduled to be released in August, but we got delayed due to heavy beta testing of new methods. Help file is also being prepared.
There are no known bugs at this time. If you find some bugs, please report to sedlan@ptt.yu, and we will send you source code for free, once the bug is corrected. Please remember to include your email address, otherwise we will not be able to send you the source.
Email address sedlan@ptt.yu is available for all your comments, questions and ideas. If you'd like to see some additional functionality in this component, please contact us.
By registering one or more licenses, you have the right to incorporate this component into as many as you like applications royalty-free.
If you decide to purchase license for this, or any other #7 Component, you will get one year upgrades free of charge. New versions of components will be available to you at significantly lower price after the period of one year (during which you get all new versions for free). You will also receive a phone number for limited technical support.
Visit http://sedlan.tripod.com/products.htm and register online. All major credit cards apply through secure Internet protocol. You can also register via fax, international mail order, bank wire, Postcheque, UK Cheque or US Check.
Please read carefully License.txt file before using this software.