Thanks, Doug. I have a vague memory of reading something about "me" in the VBS Reference, but was (am?) still too green to realize what I basically skipped!

Dave


At 02:00 PM 4/30/2012, you wrote:
My previous message may well have cleared up all but one issue in this
post. For the one remaining one though: "me" is a VBScript value,
available inside class functions, that is equal to the object against
which the method is being run. You do not have to declare or
initialize it; it's just there, rather like the number 5 is just
available to you without any extra effort. If you do

dim s5 : SET S5 = NEW CLS_Stack.init(MaxDepth)
s5.push(123)

the methods init() and push() in clsStack could use "me" freely.

There actually seem to be some restrictions on how "me" can be used,
but I don't fully understand them. I do know that you can return it as
a function result, and thus allow things like our cute class
initialization stunt as well as method chaining. For an example of the
latter, suppose your push() method returns me as its value. You could
then write

s5.push(1).push(2).push(3)

Some people like this ability, and some problems simplify nicely by
using it, such as our init example.

On Mon, Apr 30, 2012 at 01:48:16PM -0700, David Helkenn wrote:
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

--
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