01-29-2013 02:30 PM
Hey gents,
I was wondering if there is any way to create and then access to the pieces of the arrays/vectors by field names instead of by position.
That's what I mean, could I create something similar like this;
Dim MyFriend
MyFriend=(name="mike",last="Miller"....)
' and then access by name
someone=MyFriend(name)
I'm working with some large arrays and therefore is hard to remember which field is in which position
Thanks!!
Javier
Solved! Go to Solution.
01-30-2013 01:03 AM
Hi Javier,
I’m not sure whether I understand you correct – so I assume with “array/vector” you meant a channel in DIAdem. If so, you have the DATA-API in DIAdem since several years. Here are some examples (based on the dataset “Example_Data.TDM” which is installed with DIAdem):
Dim oMyFriend set oMyFriend = Data.GetChannel("[1]/Speed") ' ... msgbox oMyFriend.Size ' ... ' or ' ... Dim oMyListOfFriends set oMyListOfFriends = Data.CreateElementList oMyListOfFriends.Add(oMyFriend) oMyListOfFriends.Add(Data.GetChannel("[1]/Torque")) ' ... msgbox oMyListOfFriends(1).Name msgbox oMyListOfFriends(oMyListOfFriends.Count).Name
Do you mean those things?
Greetings
Walter
01-30-2013 01:05 AM - edited 01-30-2013 01:06 AM
There is a dicitionary object that can be used for lookups
Set Dict = CreateObject("Scripting.Dictionary") Call Dict.Add("Mike", "Miller") IF Dict.Exists("Mike") THEN dim someone : someone = dict.Item("Mike") end if
Compare can be set to text compare. Check dictionary in the DIAdem help.
The second argument can also be a class object which is assigned by use of "set".
01-30-2013 08:23 AM - edited 01-30-2013 08:31 AM
Hey AndreasK, thanks!!,
The "dictionary" was exactly what I meant, an "associative array". This solves my "problem"!! I used to work with similar sintax in other languages and working w/o it was being painful!!!
Walter_Rick thanks also for answering!!!
Javier