Vbscript samples

Could some one provide me with a sample set of vbscript for Toad Data Modeler, 6.4?

I can’t find any simple samples, like init the script and loop trought all entities.

Thanks.

Hello jmo,
can be JScript instead VBscript. All examples are in JScript, I’m able provide to you almost everything possible in TDM in Jscript.

Daril

Hi jmo,

This example in VBscript change all key attributes to Not Null:

Sub main()
  Set TDMLog = System.CreateObject("Log")
  For i = 0 To Model.Entities.Count-1
    Set Ent = Model.Entities.GetObject(i)
    For j = 0 To Ent.Attributes.Count-1
      Set Attr = Ent.Attributes.GetObject(j)
      If Attr.KeyConstraintItems.Count > 0 then
        If not Attr.NotNull then
          Ent.Lock
          Attr.NotNull = true
          TDMLog.Information("Attribute "+Attr.Name+" in Entity "+Ent.Name+" is set to Not Null")
          Ent.UnLock
        End If
      End If
    Next
  Next
End Sub

But I strongly recommended you using JScript.

Same example in JScript:

function main()
{
  for (i=0; i<Model.Entities.Count; i++)
  {
    Ent = Model.Entities.GetObject(i);
    for (j=0; j<Ent.Attributes.Count; j++)
    {
      Attr = Ent.Attributes.GetObject(j);
      if (Attr.KeyConstraintItems.Count > 0)
        if (! Attr.NotNull)
        {
          Ent.Lock();
          Attr.NotNull = true;
          Log.Information("Attribute "+Attr.Name+" in Entity "+Ent.Name+" is set to Not Null");
          Ent.UnLock();
        }
    }
  }  
}

Daril,

Thank you for reply to my request.

Yes, I’ve come to the conclussion myself, that I have to re-write my ‘very old, +10 years’ vbscript to jscript. I think it’s worth the hard work.

Most of the time, I have a idea of what I want to do/modeling. But it is sometime difficult to find the way how to acces, set or change a particual setting within a model. Eg. how do I access an entity collation setting and clear or change it?

The hard work also have a benefit in the future.

Thank you.

/John

Mario

I got the point, that Jscript is the way of doing it now.

Soo I will following your recommendation and re-write my VB into Jscript.

Thank you for your reply.

/John