Where Can I find specific Information on TDM's jscript or vbscript language capabilities

Hi, I am not sure if this is the appropriate place for this request, however I have not figured out a better place to ask it.

I am New To Toad Data Modeler.

I have learned how to use the scripting Window very well via the examples that have been available to me to manipulate Data within the TDM MetaModel.

However, Jscript examples or vbscript examples I have found on the Web are not executable via the Scripting Window in TDM so I believe that it is a Customization of jscript or vbscript unless I am doing something wrong.

And the reason I am looking into examples is because I have been trying to see if via jscript or vbscript using the scripting window If I can redirect output to a file

What I mean is In the small jscript script below which lists the attributes of 2 entities, If I wanted to write output it to a file called as example “C:\toadoutput.txt” instead of the only thing currently I can do which is to output to the log buffer using the line Log.Information command.

Is that possible ?

Also, Is there a way within jscript or vbscript like in the example below to filter entities by there discovery within a workspace. Meaning, if I have Table_1 and Table_2 in my Model, and Table_1 is currently a EntityShortcut in a Workspace called “AnthonyWS” Is there a way to only find entities which are linked to the Workspace “AnthonyWS”

Any Assistance in this would be appreciated as I am looking to write some Custom Reports in which are Custom Enough to be best served via a Custom Script that I write.

function main()
{
var app = System.GetInterface(‘Application’);
var Model = app.Models.GetObject(0);
var e, a, Entity, Attribute;
for (e=0; e<2; e++) // iterate entities
{
Entity = Model.Entities.GetObject(e);
for (a=0; a<Entity.Attributes.Count; a++) // iterate attributes
{
Attribute = Entity.Attributes.GetObject(a);
Log.Information('Entity = ‘+Entity.Name+’ Attribute Name '+Attribute.Name);
}
}
}

Thanks

Hello,

there are more possibilities how write output to file. First is by standard methods of JScript by “Scripting.FileSystemObject”.

var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var ForReading = 1;
var ForWriting = 2;
if (fso.FileExists(‘C:\Test.txt’))
var f1 = fso.OpenTextFile(‘C:\Test.txt’, ForWriting);
else
var f1 = fso.CreateTextFile(‘C:\Test.txt’, ForWriting);
f1.Write(‘Test2’);
f1.close();

Second is by using some internal TDM object, in this case it is TextStream.

var TextStream = System.CreateObject(‘TextStream’); //System is TDM object
TextStream.WriteLine(‘1. line’);
TextStream.WriteLine(‘2. line’);
TextStream.FileName = ‘C:\Test2.txt’;
TextStream.SaveToFile();

A lot of information you can find in Referential Guide, but not all. So doesn’t hesitate to ask me.

If you looking for more information about TextStream please open Referential Guide and to index tab type “TextStream”.

TDM use Jscript but without some implicit system objects so you need to create it explicitly (new ActiveXObject).

Daril

Hello Daril

That Is Perfect and Exactly What I needed.

Thank you for the Quick Response.

Anthony V