hoDemo3Par - Helmut-Ortmann/EnterpriseArchitect_hoTools GitHub Wiki

hoDemo3Par.vb

Example VB Script to use with hoTools Script. Just:

  • Create a Normal Script Group
  • Create a VB Script
  • Copy and past / replace existing code with the following code into a VB Script.

Code

'EA-Matic
' Usage of Geert Bellekens Script Framework to administer Scripts recommended
'[path=\Framework\ho\hoTools]
'[group=hoTools]
'option explicit

!INC Local Scripts.EAConstants-VBScript
'----------------------------------------------------------------------
' Dim doesn't work (syntax error, used in EA for IntelliSense)
' Object 'Session' doesn't exist (use  Repository.WriteOutput "Script", "MyTest",0)
' Var 'Repository' is loaded by script environment
' You may create an instance 'EAAddinFramework.Utils.Model' of the first running EA-Instance

'---------------------------------------------------------------------
' Par1: ModelItem (diagram, package, element)
' Par2: ObjectType
' Par3: Model (methods and attributes see code in https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools.git)
function hoDemo3Parameter(ModelItem, ObjectType, Model)
   ' The EA default variable 'Repository'
    'Repository.ClearOutput("Script")
    Repository.EnsureOutputVisible("Script") 

    ' just output the parameters
	Repository.WriteOutput "Script","Par1: '"+ CStr(ObjectType) + "' Par2: '" + ModelItem.Name + "' Par3: '" + Model + "'",0
	
	' Get Repository via Model object.
    set m = CreateObject("EAAddinFramework.Utils.Model")
    ' Create new Model Object with the first running EA instance
	set rep = m.Repository
	rep.EnsureOutputVisible("Script") 
	rep.WriteOutput "Script","Par1: '"+ CStr(ObjectType) + "' Par2: '" + ModelItem.Name + "' Par3: '" + Model + "'",0
	
	itemType = "unknown"
	Select Case ObjectType
	    Case otElement
			itemType = "Element"
		Case otPackage
			itemType = "Package"
		Case otDiagram
			itemType = "Diagram"
		Case otAttribute
			itemType = "Attribute"
		Case otOperation
			itemType = "Operation"
	End Select
	rep.WriteOutput "Script", "hoDemo3Parameter: item type='" + itemType + "', name='" + ModelItem.Name + "' found.",0
	rep.WriteOutput "Script","----------------------------------------------------",0

end function