Productivity pack contains three macros.
Select Macros | Productivity | Add Entities to run the macro.
The same macro can be executed from Workspace.
New dialog opens. Specify entity captions, one per line.
Click Execute to create the new tables.
The tables will be added to your model.
In case your workspace option Autocomplete is activated the entities will appear also on our workspace.
Select Macros | Productivity | Add Attribute to Selected or All Entities to run the macro.
New dialog opens. Specify caption, name, data type and other options.
Tip: If you want to use table caption/name as prefix, type a "space" as the first character in Attribute Caption field and an underscore as the first character to Attribute Name field.
Note that if you select the Add to Key checkbox, the Not Null checkbox disappears.
In case you selected an entity, the attribute will be added to the selected entity. Otherwise the following dialog opens.
Click Yes to add attribute to all entities.
Result:
Verification: There is some basic verification of the required items.
Notes:
Select an attribute in physical Model Explorer, right-click and select Macros | Copy Attribute to All Entities.
It is possible to run the macro also from Object Viewer.
Result:
|
Note: The attribute will be added only to the entities which don't have an identically named attribute. |
You can find them in Package Explorer in section Productivity Pack | Macros.
Right-click any macro and select Edit Source Code to see JavaScript code.
Rename Objects Pack contains the following macros:
This macro renames primary keys to PK_<tablename>.
When you create a new entity, its primary key is named Key1.
When you execute the macro, the key name and caption changes.
Notes:
This macro renames relationship captions and names and modifies them to:
New caption: <parenttablecaption> - <childtablecaption>
New name: <parenttablename>_<childtablename>
By default, relationships are named as Relationship1, Relationship2 etc. When you execute the macro, the following result is achieved:
Notes:
This macro renames Table and Column check constraint names and captions.
By default, Toad Data Modeler names check constraints as CheckConstraint1,2,3 etc.
After you execute the macro, check constraints will be renamed to CHK_<tablename>_<index> and CHK_<columnname>_<index>.
Notes:
This macro works similarly to the Rename Relationships macro.
New caption: <object1caption> - <object2caption>
New name: <object1name>_<object2name>
The macro renames existing View relationships.
Result:
|
Note:
|
Toad Data Modeler allows you to create a macro in Package Explorer or Script Explorer and modify its properties to display the macro either in main menu or pop-up menu (of specific object or on the Workspace etc.).
Older versions allowed you to define such macros via a script written in Script Editor. To execute the script directly, you simply selected the macro in the appropriate menu.
Toad Data Modeler version 3.5 is bringing some improvements for using macros - visual components for macros (User Forms). So, now when you select a macro, a user form can display.
To create a form, use the object System that is registered in every script.
The method you need is called CreateForm and has four optional parameters:
Example:
var form = System.CreateForm(‘FormName’, ‘Form Caption’, 200, 150);
AddControl(ControlName: widestring, ControlType: Integer): IDispatch;
See the following table:
- 1 | - Edit Box |
- 2 | - Check Box |
- 3 | - Memo |
- 4 | - Panel |
- 5 | - Label |
- 6 | - Group Box |
- 7 | - Radio Button |
- 8 | - Combo Box |
- 9 | - List Box |
- 10 | - Button |
This function adds control on the form.
ShowModal()
This function displays the form.
AddUserVariable(AName: widestring, DefaultValue)
This procedure adds a variable on the form. The variable is then accessible in events via calling the Instance.VariableName. The variable is accessible across events. If you change a content of the variable in one event, the changed status will be accessible in another event.
RegisterObject(AName: widestring, AObject: IDispatch)
Use this procedure to register objects in events.
Caption – Heading of the form.
CloseAfterExecute – True – When you click Execute, the code will be executed and the form closes. False – The form will not close after execution. Default: False.
ExecuteMethodName – Name of method that should be executed when you press the Execute button.
ExecuteScriptName – Name of script for calling out the method when you click the Execute button.
|
Note: If you don’t want to use the button Execute, do not set up the properties ExecuteMethodName and ExecuteScriptName. The button will not be visible on the form then. |
To assign events, assign the component of particular event to properties of names NameEventScriptName, NameEventMethodName with reference to particular service method.
Example:
Button.OnClickScriptName = ‘MyScript’;
Button.OnClickMethodName = ‘DoOnClick’;
Control is an ancestor from which all controls, including the form, inherit.
Align – Alignment of control. Possible values to use:
0 - No alignment
1 - Alignment - Top
2 - Alignment - Bottom
3 - Alignment - Left
4 - Alignment - Right
5 - Alignment – All client
AnchorTop, AnchorBottom, AnchorLeft, AnchorRight – Determines the position of control. Default place – top left-hand corner.
Parent – Control on which a control is placed. Default position of all controls is on the form and this property is not set up.
Note: Description of value Align 0..5:
alNone - The control remains where it was placed. This is the default value.
alTop - The control moves to the top of its parent and resizes to fill the width of its parent. The height of the control is not affected.
alBottom - The control moves to the bottom of its parent and resizes to fill the width of its parent. The height of the control is not affected.
alLeft - The control moves to the left side of its parent and resizes to fill the height of its parent. The width of the control is not affected.
alRight - The control moves to the right side of its parent and resizes to fill the height of its parent. The width of the control is not affected.
alClient - The control resizes to fill the client area of its parent. If another control already occupies part of the client area, the control resizes to fit within the remaining client area.
OnClick – Occurs when you click the button.
OnClick – Occurs when the check in checkbox is changed.
Event
OnSelect - Occurs when combo box is selected.
Event
OnChangeText – Occurs when text in edit box is changed.
Event
OnChangeText – Occurs when text in memo is changed.
Event
OnClick – Occurs when the button is selected.
For more properties, please read the Reference Guide (Expert Mode main menu, Expert Mode has to be enabled.). See objects: UserButton, IUserCheckBox, IUserComboBox, UserControl, UserEdit, UserFormBasic, UserForm, UserGroupBox, IUserLabel, UserListBox, UserMemo, IUserPanel, UserRadioButton, UserStrings.
Scenario You want to create a macro that will add a prefix to all attributes in your model. Solution: You will create a macro Add Prefix. The macro will be available via right-click menu on the Workspace. You want to create a user form where you will define the prefix and decide if you want to apply the change in Caption of attributes too. |
![]()
Important: Name of macro mustn’t contain spaces and other forbidden characters. The name must start with a character (not number). Then you can use characters, numbers or possibly '_'. The rules don’t refer to caption. Caption can be any title you want.
- Macro menu,
- pop-up menu,
- both places.
Parameter Path specifies position in main menu (or pop-up menu). Example: 'Test\My Items'.
In this example, you decide to display it only in pop-up menu.
Path box is empty as 'Macros' item is set as default.
![]()
© 2023 Quest Software Inc. ALL RIGHTS RESERVED. Feedback Terms of Use Privacy