Scripting

Top  Previous  Next

ModelRight implements a COM/ActiveX interface for accessing and manipulating a model's objects and properties programmatically.  It uses this interface internally from VB Scripts to generate DDL.  You can write your own VB Scripts that use this within ModelRight to generate DDL, create reports, perform custom validation, do batch processing, etc...

The scripting engine resides in a DLL named SCF.DLL.  If you want to access your Model's information outside of ModelRight, you need to register this DLL (i.e. regsvr32 SCF.DLL).  You can then use the scripting engine from VB Script, JavaScript or any other programming language that can communicate with a COM/ActiveX control to access your Model's information.  You could even write an HTML page that loads a model and generates the page based on its contents.  For a simple example, see the sample JavaScript program SampleJavaScript.htm in the Report Files folder.

The scripting engine can be also be run from Python using the pywin32 module, which handles COM objects.  After installing pywin32, you can write Python scripts like the following example that generates a model's DDL to a seperate file for each Schema:

 

import win32com.client
app = win32com.client.Dispatch("SCF.ScriptFramework")

 

app.Initialize()

model = app.LoadModel(r"C:\temp\test.wer")

for schema in model.AsObject().Children("Schema") :

    f = open(schema.Name() + ".sql", "w+")

    f.write(model.DDL("", "",schema.Name(), ""))

    f.close()

 

app.CloseModel(model)