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



