vbscript - How do I make my custom class compatible with For Each? -


is possible make custom container class implemented purely in vbscript (no com objects) work each statement? if so, methods must expose?

in short, no

why? create enumerable collection class

class ctest     .... end class  dim otest, melement     set otest = new ctest     ....     each melement in otest         ....     next  

the class must follow rules. need class expose

  • a public readonly property called count

  • a public default method called item

  • a public readonly property called _newenum, should return an
    iunknown interface object implements ienumvariant interface , must have hidden attribute , dispatch id of -4

and list or requirements, vbscript not include way indicate dispatch id or hidden attribute of property.

so, can not done

the way enumerate on elements stored in container class have property (or method) returns

  • an object supports indicated requirements, same object used hold elements (fast, expose information)

  • an array (in vbscript arrays can enumerated) holding references each of elements in container (slow if array needs generated on call, not return non required information)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -