For example I want to make a list of the entities with some
extra info and output is to for example a .csv file via
VB-Script.
for each tab in model.tables
...
next
When using above loop, he gives the tables in a random (?)
order.
Yes, the order will appear random without other
intervention.
If there is a way to do a sort in 1 or 2 steps I hope
someone posts that approach to the newsgroup. I have had to
use a few dozen lines of VBscript to actually sort the
objects.
Since I wanted the order of the objects permanently changed
I modified the Index property of the object’s collection;
e.g.: “Attribute = AttributeCollection.move(Index + 1,
Index)” to change the sequence of an attribute within an
entity. I can post an example if you request, but I got
most of the script from Vbscript newsgroups.
If your needs are temporary (and you don’t want to risk
accidentally saving the model) I suppose an array might be
the way to go? Or using PowerDesigner’s VBscript method
to create an ObjectCollection – but I haven’t done that
before.
Rick
You could use a Dictionary object to store the table name or code, the table
object to optimize the search of table by name.
Xiao
<Jan Huyzentruyt> wrote in message
news:40ffc888.12b...@sybase.com...
You may also sort the collection itself (The collection must be sortable, ie
of type "sorted collection", see vbscript chm in powerdesigner help).
Ex. (note the sort is absolutely not optimized -- nor really exempt of bug I
guess--, but it is not the issue there)
<<
SortCollection ActiveModel.Tables, "Name"
dim t
output "the sorted-by-Name list of tables in the model ->"
For each t in ActiveModel.Tables
output t.ShortDescription
next
sub SortCollection(pColl, sAttr)
if pColl.Count < 2 then exit sub ' don't sort a collection of one or less
element
if not (pColl.Item(0).HasAttribute(sAttr)) then exit sub ' check sAttr
attribute existence
dim i
for i = 0 to pColl.Count - 2
if (pColl.Item(i).GetAttributeText(sAttr) >
pColl.Item(i+1).GetAttributeText(sAttr)) then
output " -- need to invert " &
pColl.Item(i).GetAttributeText(sAttr) & " and " &
pColl.Item(i+1).GetAttributeText(sAttr)
pColl.Move i, i + 1
i = i - 1
end if
next
end sub
>>
Marc
"Xiao Wang" <xw...@sybase.com> wrote in message
news:410030db@forums-2-dub...
Marc.
"Marc" <us...@host.com> wrote in message news:4100c983$1@forums-2-dub...
Thank you very much.
It helps me a lot in what I wanted to do, except for one
thing :
what do you mean by "Dictionary object". I don't find not
much help on this in the documentation.
Jan
Dictionary object is documented in the "Microsoft Windows Script" online
help.
You can download it from MS web site.
Dictionary objects uses a key and a value. In your case, the key is the
table code, the value is the table object.
Xiao
<Jan Huyzentruyt> wrote in message
news:4100caf7.1c3...@sybase.com...