Book a Demo

Author Topic: Visual Bacis Arrays In EA  (Read 7975 times)

t_s

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Visual Bacis Arrays In EA
« on: August 17, 2015, 08:23:22 am »
First, I know little about Visual Basic Script (VBS) (though I know much about other non-scripting languages). I've been trying to write a VB Script to make the 'Realization' connector appear transitive across 'connected' requirements. My approach has required the use of arrays to keep track of a) a requirement's connectors that are 'Realization's and b) the elements a 'Realization' connector is connected to (i.e., client).

I've looked online and tried many many variations but none seem to work in/with EA.

Can anyone provide some guidance on how to handle arrays with VBS in EA?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Visual Bacis Arrays In EA
« Reply #1 on: August 17, 2015, 04:32:45 pm »
Standard Array's should work without an issue in vbs, but they are not all that flexible.

I often use a .Net ArrayList instead.

Code: [Select]
dim myArrayList
set myArrayList = CreateObject( "System.Collections.ArrayList" )

Adding, removing and sorting then suddenly becomes a lot easier, and you don't have to worry about redim-ing.

Geert

t_s

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Visual Bacis Arrays In EA
« Reply #2 on: August 19, 2015, 06:51:56 am »
Thank you for the quick response. After reviewing your suggestion, which I had already tried, I realized that I wasn't accessing the array correctly (e.g., for each XX in array ....).

Another item that slowed me down was an inability to find textual descriptions of the various 'objects' that constitute the EA model. The names that appear e.g., Element.ElementID, are suggestive as to the interpretation to be made, but insufficient for an understanding.

Again thank you.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Visual Bacis Arrays In EA
« Reply #3 on: August 19, 2015, 04:14:14 pm »
Quote
Another item that slowed me down was an inability to find textual descriptions of the various 'objects' that constitute the EA model. The names that appear e.g., Element.ElementID, are suggestive as to the interpretation to be made, but insufficient for an understanding.
RTFM  :D

The documentation of the complete API can be found in the help in the section Automation and Scripting | Enterprise Architect Object Model

Geert

NikoWenz

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Visual Bacis Arrays In EA
« Reply #4 on: October 25, 2018, 10:39:35 pm »
Hi,

I am trying to understand how to use Arrays with VB in EA.
Standard Array's should work without an issue in vbs, but they are not all that flexible.

I often use a .Net ArrayList instead.

Code: [Select]
dim myArrayList
set myArrayList = CreateObject( "System.Collections.ArrayList" )

Adding, removing and sorting then suddenly becomes a lot easier, and you don't have to worry about redim-ing.

Geert

I am not sure what to insert in the AddNew function as Type when I just want to stre some Strings

Code: [Select]
sub test
dim myArrayList
set myArrayList = CreateObject( "System.Collections.ArrayList" )
myArrayList.AddNew("name","Type?")
MsgBox myArrayList.GetAt(0)
end sub

Do I just miss the right Type or is the AddNew Method the wrong Method?

   

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Visual Bacis Arrays In EA
« Reply #5 on: October 25, 2018, 10:49:13 pm »
AddNew() is a method from EA.Collection, not from ArrayList.

For ArrayList you just use Add(object)

Geert

NikoWenz

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Visual Bacis Arrays In EA
« Reply #6 on: October 25, 2018, 10:57:41 pm »
Ty for ur quick reply =)

Seems I fall into the trap of using the . operator :D