From: Peter Olcott on
Iterating over the members of a class?
Is there any way to do this?


--
100% Accurate Display Screen OCR
http://www.OCR4Screen.com
From: Trevor Sullivan on
Your question is too vague to completely understand where you're going
with it. Yes, it's possible to, for example, iterate over the members of
a .NET class using PowerShell. It is also possible to iterate over WMI
properties and methods of a particular WMI class using VBscript or
PowerShell.

What type of "classes" are you trying to iterate over, and what are you
ultimately trying to achieve?

Cheers,
Trevor Sullivan
Consultant | 1E Inc.

On 8/9/2010 3:55 PM, Peter Olcott wrote:
> Iterating over the members of a class?
> Is there any way to do this?
>
>

From: Peter Olcott on
On 8/9/2010 9:43 PM, Trevor Sullivan wrote:
> Your question is too vague to completely understand where you're going
> with it. Yes, it's possible to, for example, iterate over the members of
> a .NET class using PowerShell. It is also possible to iterate over WMI
> properties and methods of a particular WMI class using VBscript or
> PowerShell.
>
> What type of "classes" are you trying to iterate over, and what are you
> ultimately trying to achieve?

I am talking about iterating over the members of a VBScript class, using
VBScript. Can this be done?

>
> Cheers,
> Trevor Sullivan
> Consultant | 1E Inc.
>
> On 8/9/2010 3:55 PM, Peter Olcott wrote:
>> Iterating over the members of a class?
>> Is there any way to do this?
>>
>>
>


--
100% Accurate Display Screen OCR
http://www.OCR4Screen.com
From: ekkehard.horner on
Peter Olcott schrieb:
> Iterating over the members of a class?
> Is there any way to do this?
>
>
Other script languages - e.g. Perl or Javascript - use enhanced
collections to organize the class members. That makes it easy to
loop over them. VBScript classes in this respect are more like C
structs. Such languages (C++, Java, or C#) have features like
introspection or pointers/references that make it at least possible
to write iterators for member access; it would even be feasible by
using inheritance from a class/interface. VBScript has no introspection,
no references to plain data elements, and no inheritance. So you picked
the worst language for your purpose.

The answer to "Is there any way to do this?", however, is "yes". If
you have lots of time to spend, are willing to pay a price of reduced
efficiency, and like work hard against the grain of language to get
what other languages offer for free, you could

(a) write wrapper/boxing classes for all simple data types

(b) collect the elements of your classes into arrays (efficient)
or dictionaries (less work)

(c) add boilerplate code to each class that gives access the elements
singularily (one level of indirection)

o.member ==> o.Properties_( "member" )
==> o.Properties_( MEMBER ) ' num constant

(d) make .Properties_ accessible for the loops


From: Peter Olcott on
On 8/10/2010 2:58 AM, ekkehard.horner wrote:
> Peter Olcott schrieb:
>> Iterating over the members of a class?
>> Is there any way to do this?
>>
>>
> Other script languages - e.g. Perl or Javascript - use enhanced
> collections to organize the class members. That makes it easy to
> loop over them. VBScript classes in this respect are more like C
> structs. Such languages (C++, Java, or C#) have features like
> introspection or pointers/references that make it at least possible
> to write iterators for member access; it would even be feasible by
> using inheritance from a class/interface. VBScript has no introspection,
> no references to plain data elements, and no inheritance. So you picked
> the worst language for your purpose.
>
> The answer to "Is there any way to do this?", however, is "yes". If
> you have lots of time to spend, are willing to pay a price of reduced
> efficiency, and like work hard against the grain of language to get
> what other languages offer for free, you could
>
> (a) write wrapper/boxing classes for all simple data types
>
> (b) collect the elements of your classes into arrays (efficient)
> or dictionaries (less work)
>
> (c) add boilerplate code to each class that gives access the elements
> singularily (one level of indirection)
>
> o.member ==> o.Properties_( "member" )
> ==> o.Properties_( MEMBER ) ' num constant
>
> (d) make .Properties_ accessible for the loops
>
>

This sort of thing was my plan. I was looking to see if there was an
easier way. If VBScript already stored its class members in an array,
and this array was directly accessible, then what I need to do would
have been easier.

It has to be an interpreted language. It has to be able to use and
create ActiveX components. It has to have classes. Ideally it should be
universally available (at least on Windows platforms) at no cost. The
language should have minimal learning curve/development time cost.

My current plans are to implement the design in VBScript, and adapt it
so that it can be applied to every language that can use and create
ActiveX components including compiled languages.

--
100% Accurate Display Screen OCR
http://www.OCR4Screen.com