#7 Components Home

#7 Components - TRestructure

        Contents

About

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 exmples on component usage.

back to top

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.

back to top

Installation

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".

back to top

History of changes

July 12, 2000. 1.20 First public release.

back to top

Future plans

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 August 2000. Help file is also being prepared.

back to top

Known bugs

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.

Back to top

Support

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.

Back to top

Benefits of registration

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.

Back to top

How to register

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.

Back to top

License

Please read carefully License.txt file before using this software.

Back to top