Doug,
This sounds like a very nice way to do what I want. It seems to hinge on the step of first initializing (defining?) the "me" object and only then calling on "Init" to establish the stack. How do the Class methods "know" the depth of the stack at any one time? I normallythink the Top is a companion to the array, so the two could be assigned within your example Init function. Pretty slick!

Thanks...

Dave



At 11:03 AM 4/30/2012, you wrote:
If you're using an array for your stack, you should be able to say
"private someStack" for the in-class declaration but omit any size.
Then in your init function:

  public function init(size)
        someStack = array(size)
    set init = me
  end function

On Mon, Apr 30, 2012 at 10:52:03AM -0700, David Helkenn wrote:
Thanks, Doug,
This certainly looks straight forward enough, yet there remains some
confusion for me. I am under the impression that the variables the
class references have to be declared within the class' scope -- i.e.,
class blah
...
' Declare the class' variable here:
private someStack ' AARRGGGG how many?
...
' your init routine here.
...
end class

so, how the class set aside the need space when it does not know how
much to use until "init" is called?

Dave

At 10:32 AM 4/30/2012, you wrote:
>I may be missing something, but it sounds like you can solve this
>issue not with a set of classes, but with one class and a set of
>instances of that class. You want a Stack class where you can create
>an instance with a set number of stack positions.
>
>VBScript does not allow parameters on the initialization method,
>but you can make your own secondary setup function and make it
>return the object being created, then use a pretty intuitive syntax
>to do this anyway:
>
>class Blah
>  private sub Class_Initialize
>    :
>    :
>
>  public function init(p1)
>    ' ... set things up using p1 as needed ...
>    ' This next line makes the below syntax work.
>    set init = me
>
>dim o : set o = new Blah.init(5)
>
>On Mon, Apr 30, 2012 at 10:20:35AM -0700, David Helkenn wrote:
>Hello,
>Does VB Script support a way to parameterize a class? In some
>languages, it is possible to define a 'virtual' or 'generic' class,
>such that when it is instantiated, the developer supplies the required
>parameters. For example, a virtual stack may be one number deep in one
>instance and another depth in a second instance. Or, the contents of
>the stack may be trucks in one, cows in a second, or temperatures in a
>third. In other words, it might be possible to define stacks of
>differing depths, differing objects, or both. For example, supply the
>required parameters and one could get a stack of up to 8 cows, etc.
>
>I'm not finding any way to have half a dozen 'stacks' for my data
>objects -- one stack of four, another of 13, and the rest with 22.
>
>Thanks for any help with this one!
>
>Dave
>
>--
>Doug Lee, Senior Accessibility Programmer
>SSB BART Group - Accessibility-on-Demand
>mailto:[email protected]  http://www.ssbbartgroup.com
>"While they were saying among themselves it cannot be done,
>it was done." --Helen Keller

--
Doug Lee, Senior Accessibility Programmer
SSB BART Group - Accessibility-on-Demand
mailto:[email protected]  http://www.ssbbartgroup.com
"While they were saying among themselves it cannot be done,
it was done." --Helen Keller

Reply via email to