Chris:
Thanks! I had briefly thought about that, but no so absolutely little about
JScript I figured it would take too long to learn it well enough to get what
I needed. Your list below provides food for thought. However, I would
agree to be somewhat concerned about performance issues, and the fact that
JScript can't natively see VBScript functions/sub as you say makes it less
appealing.
As for performance, I've already decided we'll implement a caching system so
performance isn't an issue so much as fast implementation, maintainability,
robustness, and composability.
As for not needing events, you are thinking events to be like the are
commonly used i.e. OnClick, not have the can be used in all cases. For
example, let's assume you have a communications component; it might have an
"OnBytesReceived" event. In my case I've attached a script I wrote that
uses one event called PagePartClass. It lets someone define a simple
"PagePart" for our website (you can see this code live in action on our home
page at
http://www.xtras.net)
The PagePart is a class with properties like Name, Title, HeadClass,
ImageUrl, Text, etc. If "Text" is not empty, it displays the value in the
Text property. If Text IS empty, it concatonates the value in Name to
"_ShowText" and calls that Sub (i.e. Sub ppLeadingVendors_ShowText). And it
works GREAT.
The problems I was trying to solve was not in the example but in some much
more complex code where I have events like "_BeforeRecordAdd" and
"_AfterRecordAdd" that I only want to run if they exist. If they don't
exist, I don't want them to run, but if they do exist I want to run with w/o
ON ERROR RESUME NEXT in force. Further, I would like to be able to display
an error message prior to calling like the following
"MyModule_BeforeRecordAdd expected two parameters but none were passed." As
it, I get a cryptic error message that requires a lot of time to trace.
Of course if we switch to ASP.NET, I'll have none of these problems, just
not ready to do that yet. :-)
-Mike
[quoted text, click to view] "Chris Hohmann" <nospam@thankyou.com> wrote in message
news:euCoMvVAEHA.1792@TK2MSFTNGP12.phx.gbl...
>
> Mike-
>
> Have you considered looking to JScript to achieve some of the reflective
> features your looking for.
>
> IsFunction = typeof function
> IsProperty = object.hasOwnProperty(proName)
> IsMethod = Use object.hasOwnProperty AND typeof object.property
> ParameterCount = function.length
> Parameters = function.arguments
> CallByName = JScript supports optional parameters
> CallStack = function.caller
> Global Namespace = intrinsic global object
>
> I'm not recommending that you rewrite your existing code. However, you
> could create JScript wrappers for your VBScript classes so you could
> make use of the above. Also, you may consider creating a generic wrapper
> for all VBScript classes. Since JScript allows you to enumerate objects,
> you could pass in a VBScript class instance to the generic wrapper which
> would dynamically "implement" the class. Here's a proof of concept on
> enumerating a VBScript class instance.
>
> <script language="VBScript" runat="SERVER">
> Class foo
> Public x
> Function init()
> x = 123
> End Function
> End Class
>
> Dim f
> Set f = New foo
> f.init()
> enumerate(f)
> </script>
>
> <script language="JScript" runat="SERVER">
> function enumerate(obj){
> var i;
> for(i in obj){
> Response.Write(i + ":" + (typeof obj[i]) + "<br>");
> }
> }
> </script>
>
> The typeof call will return "Unknown" for VBScript functions/subs since
> it has no idea what a VBScript function is (nor should it). You could
> replace the typeof call with the VBScript functions you've developed. I
> was reluctant to send this reply since I am certain there are
> considerable performance issues related to burdening ASP with this
> additional abstraction layer. As such, dynamically implementing the
> VBScript class is left as an exercise for the reader. :) I would
> strongly suggest you rethink your class execution model. I remain
> convinced that attempting to carrying over the VBA event/messaging model
> to VBScript is inappropriate due to the stateless nature of the ASP. In
> layman's terms, ASP should not be expected to handle OnClick. Could you
> provide some more specifics on the class model? Perhaps someone here
> could offer an alternative that avoids the above chaos.
>
> HTH
> -Chris Hohmann
>
>
>
>
>
begin 666 PagePartClass.inc
M#0H)4V5T('!P/2!.97=086=E4&%R="@@(G!P3&5A9&EN9U9E;F1O<G,B+"),
M96%D:6YG(%9E;F1O<G,B*0T*"5=I=&@@<' -"@D)+D1I<W!L87E,96%R;DUO
M<F4]($9A;'-E#0H)"2Y(96%D0VQA<W,](")B;'5E:&5A9"(-"@D)+E=I9'1H
M/2(Q.# B#0H)"2Y3:&]W#0H)16YD(%=I=&@-"@T*#0HG7U]?7U]?7U]?7U]?
M7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?7U]?
M7U]?7U]?7U]?7U]?7U]?7U]?7U]?7PT*4W5B('!P3&5A9&EN9U9E;F1O<G-?
M4VAO=U1E>'0-"B4^#0H\=6P^#0H\;&D^/&$@:')E9CTB+W9E;F1O<G,O26YF
M<F%G:7-T:6-S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