Author Topic: How may I debug this VBScript in EA  (Read 2440 times)

salayande

  • EA User
  • **
  • Posts: 224
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
How may I debug this VBScript in EA
« 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
    


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: How may I debug this VBScript in EA
« Reply #1 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.