Toad World® Forums

I am not sure I am Following the Instructions related to adding a Script to the Script Explorer for ultimate adding a Menu item or control somewhere to actually execute it

Hi folks

I include a JScript below for just example, Lets Say that I have a Script that I know works and Runs from the Scripting Window, Like this Script which Replaces ’ ’ with ‘-’ in Names.

However I cannot seem to figure out how to Add This as an Actual Function with its Unique name and to add it to a Menu or to a Button So All I have do do is to click the object (menu or button) and make it run.

Can you please point me to where within the UserGuide I can see where to do this.

Or if it is not too much writting, a brief Summary of how I can Do it.

function main()
{
var app = System.GetInterface(‘Application’);
var Model = app.Models.GetObject(0);
var e, a, Entity, Attribute, NewName, Index;;
Model.Lock();

for (e=0; e<Model.Entities.Count; e++) // iterate entities
{
Entity = Model.Entities.GetObject(e);
Entity.Lock();

for (a=0; a<Entity.Attributes.Count; a++) // iterate attributes
{
Attribute = Entity.Attributes.GetObject(a);
NewName=Attribute.Name;
NewName = NewName.replace(" “,”_");

Attribute.Lock();
if (Attribute.Name != NewName)
{
Attribute.Name=NewName;
}
Attribute.UnLock();
}

for (a=0; a<Entity.Indexes.Count; a++)
{
Index = Entity.Indexes.GetObject(a);
NewName=Index.Name;
NewName = NewName.replace(" “,”_");

Index.Lock();
Index.Name=NewName;
if (Index.Name != NewName)
{
Index.Name=NewName;
}
Index.UnLock();
}

for (a=0; a<Entity.Keys.Count; a++)
{
Key = Entity.Keys.GetObject(a);
Key.Lock();
NewName=Key.Name;
NewName = NewName.replace(" “,”_");

if (Key.Name != NewName)
{
Key.Name=NewName;
}

Key.UnLock();
}

Entity.UnLock();
}
Model.UnLock();
}

Thanks

Anthony Vitale

Hi Anthony,

there are two possibilities.

  1. Make Macro

Please see Macro topic in help. To macro is always registered actual model and is you have selected objects, so it will be registered too. Macro can be available from Main Menu - Macros, or with popup menu, or both.

  1. Create Button on some Properties Form

You can modify majority of forms in Toad Data Modeler(Entity Properties, Attribute Properties etc.). You can create button on this form and on this event stick your own script.

This case is little harder, and I think point 1 will be better for you, but if you would like I can provide example.

Daril

Hi Daril

Excellent, I did not think Macro I was thinking I would need to extend the objects, but the use of Macro is 100% Excellent and Exactly What I am looking for.

I have already Done it Making Macros from my Current Code via reading the Help Doc so No need for you to give Me an Example.

And Just So I am 100% Sure. As I will be Creating a Number of More Macros.

It Appears that The “My Package.txg” file is found in the %USERPROFILE%\Documents\Toad Data modeler{Standard Installation Folders Name}\Packages and then a Class Identifier In my Case being {DCB5CB9B-CF65-4350-86B5-285D246FC5AC}

So My Last question is regarding TDM Version Upgrades.

As Long as when I Upgrade the software I do it with the option to take the Prior Installation Code and use it for the New Version then this My Package Custom Code will come along for the Ride.

Otherwise I will need to create new Macros from the Exported txg.

Is that Correct ?

Are there any Nuanced things I need to keep in mind regarding Software Upgrades If I have Custom Macros in MyPackage, As I am assembling Instructions to Give to 2 other DBA’s in My company to use the Tool and the Macros Are part of that, So when they have to perform a TDM upgrade I want to make sure to tell them what to do if anything special to keep the logic working.

Thanks for All you Help, You Are Great.

Thanks

Tony V

From: Daril [mailto:bounce-Daril@toadworld.com]

Sent: Monday, November 20, 2017 3:30 AM

To: tdmscript@toadworld.com

Subject: RE: [Toad Data Modeler - Scripting & Customizations Discussion Forum] I am not sure I am Following the Instructions related to adding a Script to the Script Explorer for ultimate adding a Menu item or control somewhere to actually execute it

RE: I am not sure I am Following the Instructions related to adding a Script to the Script Explorer for ultimate adding a Menu item or control somewhere to actually execute it

Reply by Daril

Hi Anthony,

there are two possibilities.

  1. Make Macro

Please see Macro topic in help. To macro is always registered actual model and is you have selected objects, so it will be registered too. Macro can be available from Main Menu - Macros, or with popup menu, or both.

  1. Create Button on some Properties Form

You can modify majority of forms in Toad Data Modeler(Entity Properties, Attribute Properties etc.). You can create button on this form and on this event stick your own script.

This case is little harder, and I think point 1 will be better for you, but if you would like I can provide example.

Daril

To reply, please reply-all to this email.

Stop receiving emails on this subject.

Or
Unsubscribe from Toad Data Modeler - Scripting & Customizations Forum
notifications altogether.

Toad Data Modeler - Scripting & Customizations Discussion Forum

Flag
this post as spam/abuse.

Hi Anthony,

at first I would like to tell you a few information about custom packages. You are right, that custom packages are stored in folder "%USERPROFILE%\Documents\Toad Data modeler{Standard Installation Folders Name}\Package{DCB5CB9B-CF65-4350-86B5-285D246FC5AC}" by default. You can change this folder from settings.

User can create his own package from Menu "Expert Mode - Customization - New Custom Package" In this case is important "Package Dependency" and "Package Extension" of this package. My recommendation is set one Package Extension on database package that user want to extend. For Example:

Database Oracle 10g - functions only for Oracle 10g

Database Oracle - functions for all Oracle Platforms

Physical Entity Relationship Model - functions for all Physical Models

Toad Data Modeler - functions for all

My Package is special custom package, because it extend all databases and logical model packages. So if you want macro only for some database it would be better place it to separate package. If you work only with one database platform you can choose My Package all time without any problem.

When you have installed version 6.2 and you install version 6.3 (6.2 and 6.3 are only example it will be same for different versions), you can choose upgrade or side by side installation. It dependent on install folder. When choose same folder for version 6.3 it will be upgrade, otherwise side by side installation(It's mean both version are installed on computer).

When you first run version 6.3 you get this dialog for upgrade

FirstRun.png

When you choose "Use Configuration of Uninstalled Toad Data Modeler" and select configuration from version 6.2, your settings and packages will be preserved.

For Side By Side Installation you should get similar dialog, but with other enabled choice

FirstRun2.png

So you can use Copy Configuration of Installed Toad Data Modeler and Select Configuration from 6.2. (This screenshot is for combination 6.3 and 6.4 version) In this case your packages will be preserved.

You can have more configurations on your computer in this case First Run dialog can has more enabled checkboxes, but if you select configuration from 6.2 you will have always preserved custom packages.

Btw: When you use older configuration, you use same path for custom packages.

Regards

Daril

Hi Daril

I Feel Like I owe you a Beer or at least a Very Big Thank you.

You have been the greatest in responding with Accurate and easy to understand information

Above is Great And perfect for me.

Thanks for your help in All this.

Thanks

anthony vitale

Hi Anthony,

glad to help. Don’t hesitate to ask. :slight_smile:

Daril