Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: salayande on December 27, 2009, 10:37:44 am

Title: How may I debug this VBScript in EA
Post by: salayande on December 27, 2009, 10:37:44 am
Dear all,

I started experimenting with the scripts and created one below but it is not doing what I want.

How may I get and use a debugger to correct this script. Can anyone suggest what I have done wrong on this script. Any help is appreciated.

kind regards

Option explicit
sub ChangeElementStereotype()

dim thePackage as EA.Package
set thePackage = Repository.GetTreeSelectedPackage("Test Model")
      if not thePackage is nothing and thePackage.ParentID <> 0 then
      dim i
            Session.Output( "Working on package " & EA.Package.Name)
      'get elements
      dim elements as EA.Collection
      dim currentElement as EA.Element
      set elements = thePackage.Elements
            for i = 0 to elements.Count - 1
                  'get each element
                  set currentElement = elements.GetAt(i)
                  'change stereotype
                  set currentElement.Stereotype = "BusinessEntity"
                  'update element stereotype
                  currentElement.Update()            
            Next
            'refresh elements
            elements.Refresh()
            'report element updated
            Session.Output( "Done!" )
      else
            ' No package selected in the tree
            MsgBox( "This script requires a package to be selected in the Project Browser.")
      end if      
End sub
    

Title: Re: How may I debug this VBScript in EA
Post by: Eve on January 04, 2010, 02:16:08 pm
A possibility is errors with using parenthesis on function calls.

My experience is that you can't use parenthesis when you aren't using the return value.  I can see multiple places where you have done that.