Welcome! Log In Create A New Profile

Advanced

Collections

Posted by kevinw 
kevinw
Collections
June 06, 2008 05:52PM
Is it possible to somehow create a collection in WinDev (like you can in VFP and .NET) ads opposed to an array? I would want to use this in a WD class.

TIA, Kevin
Peter Holemans
Re: Collections
June 06, 2008 10:31PM
Hi,

I'm working on getting familiar with C# currently (in the light of an AgilePoint from Ascentn and a SharePoint MOSS2007 product training) and I can tell you that the standard Arrayxxx functions of WX provide a lot of the Collection functionalities of .Net (Array of objects, search (even binary), sort, etc...) but it might be missing some 'Generic' implementation features like the List<T>, Queue<T>, Stack<T> , etc... you would find in the .Net 3.0 framework.

So in short: the Arrayxxx functions of WX provide more features than the simple array concept in .Net but aren't as complete, generic and powerful as the Collection concept in .Net, it's somewhere in between.

Just my 2 cents,

Peter
BLS
Re: Collections
June 11, 2008 12:48PM
I agree with Peter. WD arrays (fixed, dynamic) and associative arrays (HashMap) are already quit flexible. But in case that you'd like to build your own collection classes WD lacks support for generics (meta-programming)

please note that the following code is not valid. Here a stack based on a dynamic array...
stack is class( [T] )  // note  [T]
  PRIVATE
   _value  is dynamic array of 0 T  // Bingo
  procedure push()

  procedure pop() 

  procedure count()
     
END
// use case
iStack is stack([integer])
sStack is stack([string])

well, we don't have generics. A workaround is to implement an abstract base class like :
abstractStack is class
   procedure virtuelle push()
// etc.
END

intStack is class 
  inherits stack
 _value  is dynamic array of 0 integer
// etc.
end

Probabely another option is to use the variant data type.
ie.
flexStack is class
   _value  is dynamic array of 0 variant
  _targetType is int
   procedure constructor(tt is int)
       _targetTpe = tt

end

// now your constructor should init the targetType member. 
x is Stack(wlEntier)

But you have some overhead; ie. you have to convert the variant to _targetType

Finally you can use the system.collection DOT NET classes. I doubt that you can access system.generics.collection.


I really wish we have generic language support, of course in conjunction with operator overloading ... So that we are able to write

MyStack += 10  //  smiling smiley

HTH Bjoern
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: