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:
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.
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.
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 – Justify
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.
OnSelect - Occurs when combo box is selected.
OnChangeText – Occurs when text in edit box is changed.
OnChangeText – Occurs when text in memo is changed.
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.
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.
Toad Data Modeler implements the concept of metamodels. Metamodels are accessible only in Expert Mode (via Package Explorer).
Metamodel is a graphical representation of objects, classes, methods and relationships between them in a specific Package.
Using metamodels, you can create your own classes, methods and properties and define relationships between those items and items that are created in the application by default.
Important: It is recommended to only use lower and uppercase letters for naming your objects in metamodels (no numbers and special characters).
Example: The metamodel of Oracle package