Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic System Architect (steve huntington)
Decrease font size
Increase font size
Topic Title: change definition's propertys via VBA?
Topic Summary:
Created On: 30-Jul-2008 08:20
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 30-Jul-2008 08:20
User is offline View Users Profile Print this message


chunjia wang

Posts: 39
Joined: 11-Oct-2007

Hi,all.
I want to change the definition's property via VBA. The text property can be modified by function SetProperty("PropertyName" , "Value").
But , the property with control "combobox" , I can not change its property value.
if I use the function "SetProperty", its value can be changed , I can get it via the funciton "GetProperty" , but can not be displayed.
for example , In the sample encyclopedia , in the system type definition , the definition "Hotel Booking System", its "Related SBBs" property is mulity values "combobox", I can not change its values.
How should I do ,please?
Thanks.
Report this to a Moderator Report this to a Moderator
 30-Jul-2008 10:16
User is offline View Users Profile Print this message


Peter Crabb-Wyke

Posts: 73
Joined: 3-May-2007

As far as I am aware that should work. I have a macro built for us by a Popkin consultant (so its been working fine for years) which uses:
Call defDefinition.SetProperty(gstrProperty, strPropertyValue)
as a generic for adding a value to any field.

I would suggest double checking the spelling of the values that you are adding to make sure that they are permitted values. Also check for quotes, are you inserting them when not needed or omitting them when needed?
Report this to a Moderator Report this to a Moderator
 31-Jul-2008 16:55
User is offline View Users Profile Print this message


Elvin Stern

Posts: 9
Joined: 18-Jul-2006

I think you are referring to a property that is a "List Of". In that case you need to use the ofCollection class because the list is a collection of objects. This is very well documented in the VBA extensibility guide.

Here is small example of how you might add an item to the list and read thru the list.

Dim SAapp As SA2001.Application
Dim defs As SA2001.SAObjects
Dim def As SA2001.Definition
Dim coll as ofCollection, idx as Long
Set SAapp = New SA2001.Application
Set defs = SAapp.Encyclopedia.GetFilteredDefinitions("", DFXAPPLICATION)
defs.ReadAll
Set def = defs.Item(1)
Set coll = def.GetPropertyAsCollection("Technology")
'add item to collection
coll.Add (Chr(34) & "New Item" & Chr(34))
coll.SetProperty
def.save
'read thru collection
For idx = 1 To coll.Count
debug.print coll.item(idx).name
next idx
Report this to a Moderator Report this to a Moderator
 7-Aug-2008 11:10
User is offline View Users Profile Print this message


chunjia wang

Posts: 39
Joined: 11-Oct-2007

thanks.
Now I can add data to "listOf".
Buf I want to know , the element of "listOf", if the data I want to add is the in one of the elements ,I add it ,if not , do not add.
How should I get the elements of "listof"?
Report this to a Moderator Report this to a Moderator
 7-Aug-2008 16:36
User is offline View Users Profile Print this message


Arif Hussain

Posts: 5
Joined: 10-Apr-2008

That is done in the last few lines.
Here is a mere re-arrangement of excellent example supplied by Elvin.

part 1: get the list of elements
part 2: loop through the listof elements
part 3: add item to listof

Dim SAapp As SA2001.Application
Dim defs As SA2001.SAObjects
Dim def As SA2001.Definition
Dim coll as ofCollection, idx as Long
Set SAapp = New SA2001.Application
Set defs = SAapp.Encyclopedia.GetFilteredDefinitions("", DFXAPPLICATION)
defs.ReadAll
Set def = defs.Item(1)
Set coll = def.GetPropertyAsCollection("Technology")

'read thru collection - elements of listof
For idx = 1 To coll.Count
debug.print coll.item(idx).name
next idx

'add item to collection
coll.Add (Chr(34) & "New Item" & Chr(34))
coll.SetProperty
def.save
Report this to a Moderator Report this to a Moderator
 8-Aug-2008 09:20
User is offline View Users Profile Print this message


Peter Crabb-Wyke

Posts: 73
Joined: 3-May-2007

If you want to automatically check if a name exists then you do that by adapting the section

'read thru collection - elements of listof
For idx = 1 To coll.Count
debug.print coll.item(idx).name
next idx

Assign the new name to a variable, lets say strNewName
Create a boolean indicator to show if the item is found, lets call it bIndicator

bIndicator = False
'read thru collection - elements of listof
For idx = 1 To coll.Count
if coll.item(idx).name = strNewName then
bIndicator = True
end if
next idx

You then perform the section "add item to collection" only if bIndicator is True.
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic System Architect forum.
There are currently 1 users logged in.
The most users ever online was 16 on 30-Oct-2008 at 14:46.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.