Toad World® Forums

Unleash the power of Scripting!


#1

As you already may know from the help files and manuals, the customization in Toad Data Modeler is based on running scripts.

In this forums section you have been provided with some scripts you can run in TDM 's Scripting window. This Scripting window has some limitations, e.g. you cannot directly modify a model (you have to select the model index in the script code), you cannot run other scripts…

Now consider a button on the Entity Properties form. If you have such button, you can call other scripts and in the FmPEREntity* script you have the possibility to modify objects from the model (you call Instance.SomeMethod). The drawback with this would be

  1. Modification of the Entity Properties form
  2. Possibly modification of the PEREntity* object in the Meta model
  3. Modification of the already debugged FmPEREntity* script
    plus
  4. You have an ugly looking Entity Properties dialog which you’re ashamed to show in screenshots or on presentations

The solution could be to create a helper object accessible in every model and customize its Properties dialog .

You have the possibility now to download an add-on package along with the necessary Meta model from the attachment. When you install the package, you’ll see a new Model object folder in the Application View and in the Physical Model Explorer. Just add a new Custom Scripting object to your model, like on the attached screenshot ModelScripting-AV.PNG.
Edit its Properties and modify the script FmPERScriptingObjectEdit. You have now an access to all the model objects and run the other scripts methods!

ModelScripting-AV.png

ModelScripting.zip (7.02 KB)


#2

Yeah,
for you who are more lazy than me or can’t find out in the documentation, I’m posting an installation guide here:

  1. Unzip the 2 files from the zip archive.
  2. Move the package (ModelScripting.txg file) to the user packages. You can find your folder in the Settiongs - Options - Paths - Path to Packages TDM configuration.
  3. Move the metamodel (ModelScripting.txm file) to the user meta models. You can find your folder in the Setting - Options - Paths - Path to Metamodels TDM configuration.

Run the Application now!


#3

What? You aren’t yet so familiar with JScript and TDM customization to guess what are the methods in the script doing? Or the demos crash and you don’t know why? In that case here is the demos description, what should they do:

  1. Drive listing demo

This is the proof that our script engine is capable of lots of functions that has the standard MS scripting engine from your MS Windows OS in addition to simply modify the TDM data structures.
After you click on the appropriate button, the demo will check for the logical disks on your computer and print the results in an Internet Explorer window in a (very simple and rough indeed :slight_smile: ) table.
Here you can also notice that an external script method is called. You don’t have to search a possibly very complex script when you need to edit one piece of your code.

  1. Generate model demo

Tries to generate the DDL (SQL) script from your model but doesn’t save it to the disk, instead shows the report in an Internet Explorer window. You can also modify the script, so that an external custom editor can be called without modifying the TDM configuration.

  1. Create model demo

Every now and than one needs to quickly create a random model just to see, how things work in the database or in the TDM. (You won’t use your precious production model for testing now, will you? :slight_smile: )
The associated button will add specified number of entities to your model. (Yeah, don’t complain if it fails when you say -120 Entities or 12fud14 Entities )
Every Entity will have specified maximum number of attributes. Since creating a relation is not that simple, you are on your own with that.

Have fun with data types selection


#4

After a bit of struggling I was able to update the scripting demo Package. There is added a demo how to generate model objects in separate files. The Package still resides in the first message.