I need a single boolean which would be "globally" accessible to all instances of a class. Seems like the boolean should be in the class prototype, but I was troubled by the difficulty of setting the prototype boolean to true. Maybe I''m missing something? var MyObject = Class.create(); MyObject.prototype = { bSwitch: false, ... other methods and properties } var oMyOb1 = new MyObject(); var oMyOb2 = new MyObject(); alert(oMyOb1.bSwitch); // reports false alert(oMyOb2.bSwitch); // reports false Now set the value of bSwitch to true so all the oMyObN''s will see a true value. I can see the following methods... // __proto__ works in Firefox/Safari but isn''t available in IE... oMyOb1.__proto__.bSwitch = true; alert(oMyOb1.bSwitch); // reports true alert(oMyOb2.bSwitch); // reports true // This changes bSwitch for a single instance. Not in the prototype. oMyOb1.bSwitch = true; alert(oMyOb1.bSwitch); // reports true alert(oMyOb2.bSwitch); // reports false, not what we want. // Seems strange to me to reference the Class, but this works... MyObject.prototype.bSwitch = true; alert(oMyOb1.bSwitch); // reports true alert(oMyOb2.bSwitch); // reports true // It''s a little more satisfying to create a method to hide this reference to the class... MyObject.prototype = { bSwitch: false, setSwitch: function() {MyObject.prototype.bSwitch = true;} } // Now this works, and only requires a reference to a method on an instance oMyOb1.setSwitch(); alert(oMyOb1.bSwitch); // reports true alert(oMyOb2.bSwitch); // reports true // I thought all objects had prototypes. Why doesn''t this work? oMyOb1.prototype.bSwitch = true; // error: oMyOb1 is not a function Is there another method that I''ve missed? Did prototype.js extend __proto__ to work in IE? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I''ve always though the ptototype objects are not mutable after instances have been made. I.e. changes to prototypes will not update existing instances. I''ve always done this: Object.extend(MyObject, {bSwitch: false}); then MyObjec.bSwitch can be set/got globally On 21/06/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > > I need a single boolean which would be "globally" accessible to all > instances of a class. Seems like the boolean should be in the class > prototype, but I was troubled by the difficulty of setting the prototype > boolean to true. Maybe I''m missing something? > > var MyObject = Class.create(); > > MyObject.prototype = { > bSwitch: false, > ... other methods and properties > } > > var oMyOb1 = new MyObject(); > var oMyOb2 = new MyObject(); > alert(oMyOb1.bSwitch); // reports false > alert(oMyOb2.bSwitch); // reports false > > Now set the value of bSwitch to true so all the oMyObN''s will see a true > value. > > I can see the following methods... > > // __proto__ works in Firefox/Safari but isn''t available in IE... > oMyOb1.__proto__.bSwitch = true; > > alert(oMyOb1.bSwitch); // reports true > alert(oMyOb2.bSwitch); // reports true > > // This changes bSwitch for a single instance. Not in the prototype. > oMyOb1.bSwitch = true; > > alert(oMyOb1.bSwitch); // reports true > alert(oMyOb2.bSwitch); // reports false, not what we want. > > // Seems strange to me to reference the Class, but this works... > MyObject.prototype.bSwitch = true; > alert(oMyOb1.bSwitch); // reports true > alert(oMyOb2.bSwitch); // reports true > > // It''s a little more satisfying to create a method to hide this reference > to the class... > > MyObject.prototype = { > bSwitch: false, > setSwitch: function() {MyObject.prototype.bSwitch = true;} > } > // Now this works, and only requires a reference to a method on an instance > oMyOb1.setSwitch(); > > alert(oMyOb1.bSwitch); // reports true > alert(oMyOb2.bSwitch); // reports true > > > // I thought all objects had prototypes. Why doesn''t this work? > oMyOb1.prototype.bSwitch = true; // error: oMyOb1 is not a function > Is there another method that I''ve missed? Did prototype.js extend > __proto__ to work in IE? > > Sam > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Andrew Tetlaw htp://tetlaw.id.au
Nope... in fact this is one of the "dynamic" benefits of a prototype based object system. Changing the prototype of the "class" function (the function from which the other references are constructed), changes the state of all instances automatically. MyObject.prototype.bSwitch = true; is the correct way to achieve what you are looking for. Why would you want to do this by using an instance of said class? It seems to me you''d _want_ to _not_ have to know what instances are floating around in your application, so the "class" function''s prototype is the natural place to make this change. In other words, you have 10 widgets and a couple of flibbets, maybe a few woozles on your page, each of them possibly containing N instances of MyObject. Why would you want to have to know the name of one of those instances to set this switch across all of them... see my point? On 6/21/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''ve always though the ptototype objects are not mutable after > instances have been made. I.e. changes to prototypes will not update > existing instances. > > I''ve always done this: > > Object.extend(MyObject, {bSwitch: false}); > > then MyObjec.bSwitch can be set/got globally > > > On 21/06/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I need a single boolean which would be "globally" accessible to all > > instances of a class. Seems like the boolean should be in the class > > prototype, but I was troubled by the difficulty of setting the prototype > > boolean to true. Maybe I''m missing something? > > > > var MyObject = Class.create(); > > > > MyObject.prototype = { > > bSwitch: false, > > ... other methods and properties > > } > > > > var oMyOb1 = new MyObject(); > > var oMyOb2 = new MyObject(); > > alert(oMyOb1.bSwitch); // reports false > > alert(oMyOb2.bSwitch); // reports false > > > > Now set the value of bSwitch to true so all the oMyObN''s will see a true > > value. > > > > I can see the following methods... > > > > // __proto__ works in Firefox/Safari but isn''t available in IE... > > oMyOb1.__proto__.bSwitch = true; > > > > alert(oMyOb1.bSwitch); // reports true > > alert(oMyOb2.bSwitch); // reports true > > > > // This changes bSwitch for a single instance. Not in the prototype. > > oMyOb1.bSwitch = true; > > > > alert(oMyOb1.bSwitch); // reports true > > alert(oMyOb2.bSwitch); // reports false, not what we want. > > > > // Seems strange to me to reference the Class, but this works... > > MyObject.prototype.bSwitch = true; > > alert(oMyOb1.bSwitch); // reports true > > alert(oMyOb2.bSwitch); // reports true > > > > // It''s a little more satisfying to create a method to hide this > reference > > to the class... > > > > MyObject.prototype = { > > bSwitch: false, > > setSwitch: function() {MyObject.prototype.bSwitch = true;} > > } > > // Now this works, and only requires a reference to a method on an > instance > > oMyOb1.setSwitch(); > > > > alert(oMyOb1.bSwitch); // reports true > > alert(oMyOb2.bSwitch); // reports true > > > > > > // I thought all objects had prototypes. Why doesn''t this work? > > oMyOb1.prototype.bSwitch = true; // error: oMyOb1 is not a function > > Is there another method that I''ve missed? Did prototype.js extend > > __proto__ to work in IE? > > > > Sam > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > -- > Andrew Tetlaw > htp://tetlaw.id.au > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Nope... in fact this is one of the "dynamic" benefits of a prototype based object system. Changing the prototype of the "class" function (the function from which the other references are constructed), changes the state of all instances automatically. MyObject.prototype.bSwitch = true; is the correct way to achieve what you are looking for. Why would you want to do this by using an instance of said class? It seems to me you''d _want_ to _not_ have to know what instances are floating around in your application, so the "class" function''s prototype is the natural place to make this change. In other words, you have 10 widgets and a couple of flibbets, maybe a few woozles on your page, each of them possibly containing N instances of MyObject. Why would you want to have to know the name of one of those instances to set this switch across all of them... see my point? After declaring the Class, I''ve never had to mess with a class before. This takes some getting used to, and it seems strange that I can''t reference the class / constructor from an instance without knowing the constructor''s name??? I was under a mistaken assumption that oMyObj1.prototype would move up the prototype chain to reach the constructor function MyObject. If var oMyObj5 = new MyObject(); doesn''t it make sense that there should be a pointer on the oMyObj5 object which points back to the constructor function? Without __proto__, there''s no way to reach back to the constructor without knowing the constructor''s name? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
But, how can you create an instance of a class without knowing the constructor''s name? It''s much more likely you know the constructor''s name than the name of any given instance. But, try this... (not sure if its works but worth a shot if you need it)... oMyObj5.constructor.prototype.bSwitch = true; On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > Nope... in fact this is one of the "dynamic" benefits of a prototype based > object system. Changing the prototype of the "class" function (the function > from which the other references are constructed), changes the state of all > instances automatically. > > MyObject.prototype.bSwitch = true; is the correct way to achieve what you > are looking for. Why would you want to do this by using an instance of said > class? It seems to me you''d _want_ to _not_ have to know what instances are > floating around in your application, so the "class" function''s prototype is > the natural place to make this change. In other words, you have 10 widgets > and a couple of flibbets, maybe a few woozles on your page, each of them > possibly containing N instances of MyObject. Why would you want to have to > know the name of one of those instances to set this switch across all of > them... see my point? > > After declaring the Class, I''ve never had to mess with a class before. > This takes some getting used to, and it seems strange that I can''t reference > the class / constructor from an instance without knowing the constructor''s > name??? > > I was under a mistaken assumption that > > oMyObj1.prototype > > would move up the prototype chain to reach the constructor function > MyObject. > > If > > var oMyObj5 = new MyObject(); > > doesn''t it make sense that there should be a pointer on the oMyObj5 object > which points back to the constructor function? Without __proto__, there''s > no way to reach back to the constructor without knowing the constructor''s > name? > > Sam > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Also... you said: ** After declaring the Class, I''ve never had to mess with a class before. :-) you''re still thinking of javascript as a classical OO language, when it''s not. Embrace the power of the prototype. On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > Nope... in fact this is one of the "dynamic" benefits of a prototype based > object system. Changing the prototype of the "class" function (the function > from which the other references are constructed), changes the state of all > instances automatically. > > MyObject.prototype.bSwitch = true; is the correct way to achieve what you > are looking for. Why would you want to do this by using an instance of said > class? It seems to me you''d _want_ to _not_ have to know what instances are > floating around in your application, so the "class" function''s prototype is > the natural place to make this change. In other words, you have 10 widgets > and a couple of flibbets, maybe a few woozles on your page, each of them > possibly containing N instances of MyObject. Why would you want to have to > know the name of one of those instances to set this switch across all of > them... see my point? > > After declaring the Class, I''ve never had to mess with a class before. > This takes some getting used to, and it seems strange that I can''t reference > the class / constructor from an instance without knowing the constructor''s > name??? > > I was under a mistaken assumption that > > oMyObj1.prototype > > would move up the prototype chain to reach the constructor function > MyObject. > > If > > var oMyObj5 = new MyObject(); > > doesn''t it make sense that there should be a pointer on the oMyObj5 object > which points back to the constructor function? Without __proto__, there''s > no way to reach back to the constructor without knowing the constructor''s > name? > > Sam > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
yea.. the constructor thing I posted probably doesn''t exist... I just thought I remembered seeing that somewhere... On 6/21/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > But, how can you create an instance of a class without knowing the > constructor''s name? It''s much more likely you know the constructor''s name > than the name of any given instance. > > But, try this... (not sure if its works but worth a shot if you need > it)... > > oMyObj5.constructor.prototype.bSwitch = true; > > On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote: > > > Nope... in fact this is one of the "dynamic" benefits of a prototype > > based object system. Changing the prototype of the "class" function (the > > function from which the other references are constructed), changes the state > > of all instances automatically. > > > > MyObject.prototype.bSwitch = true; is the correct way to achieve what > > you are looking for. Why would you want to do this by using an instance of > > said class? It seems to me you''d _want_ to _not_ have to know what instances > > are floating around in your application, so the "class" function''s prototype > > is the natural place to make this change. In other words, you have 10 > > widgets and a couple of flibbets, maybe a few woozles on your page, each of > > them possibly containing N instances of MyObject. Why would you want to have > > to know the name of one of those instances to set this switch across all of > > them... see my point? > > > > After declaring the Class, I''ve never had to mess with a class before. > > This takes some getting used to, and it seems strange that I can''t reference > > the class / constructor from an instance without knowing the constructor''s > > name??? > > > > I was under a mistaken assumption that > > > > oMyObj1.prototype > > > > would move up the prototype chain to reach the constructor function > > MyObject. > > > > If > > > > var oMyObj5 = new MyObject(); > > > > doesn''t it make sense that there should be a pointer on the oMyObj5 > > object which points back to the constructor function? Without __proto__, > > there''s no way to reach back to the constructor without knowing the > > constructor''s name? > > > > Sam > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Also... you said: ** After declaring the Class, I''ve never had to mess with a class before. :-) you''re still thinking of javascript as a classical OO language, when it''s not. Embrace the power of the prototype. Yes, my problem is getting to the point where this "feels" right. oMyObject.constructor.prototype.bSwitch = true; // doesn''t produce an error, and doesn''t change the global value in the class prototype, so what is it changing? <script type="text/javascript"> var test = function () {} test.prototype = {color: ''red''}; var oTest1 = new test(); var oTest2 = new test(); oTest2.__proto__.color = ''blue''; alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); // blue blue test.prototype.color = ''green''; alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); // green green oTest1.constructor.prototype.color = ''purple''; alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); // green green -- not what we want </script> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hmm, interesting. Frankly, i have no idea about the constructor thing -- half expected it to throw an error. But I''m still not sure why you''re so reluctanct to use the main prototype; this is what it''s for. Ultimately, you''re looking for a way to use an instance to _get_at_ the main prototype... so why not just do it directly? It''s a feature of the language, man. test.prototype.color = ''purple''; On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > Also... you said: > > ** After declaring the Class, I''ve never had to mess with a class before. > > :-) you''re still thinking of javascript as a classical OO language, when > it''s not. Embrace the power of the prototype. > > Yes, my problem is getting to the point where this "feels" right. > > oMyObject.constructor.prototype.bSwitch = true; // doesn''t produce an > error, and doesn''t change the global value in the class prototype, so what > is it changing? > > <script type="text/javascript"> > var test = function () {} > test.prototype = {color: ''red''}; > var oTest1 = new test(); > var oTest2 = new test(); > oTest2.__proto__.color = ''blue''; > alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); > // blue blue > test.prototype.color = ''green''; > alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); > // green green > oTest1.constructor.prototype.color = ''purple''; > alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); > // green green -- not what we want > </script> > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hmm, interesting. Frankly, i have no idea about the constructor thing -- half expected it to throw an error. But I''m still not sure why you''re so reluctanct to use the main prototype; this is what it''s for. Ultimately, you''re looking for a way to use an instance to _get_at_ the main prototype... so why not just do it directly? It''s a feature of the language, man. test.prototype.color = ''purple''; I believe you are right. It took a little getting used to, so no problem, and I''m glad to have had some confirmation of that approach in this thread. So... what does oMyInstance.contructor point to and how would I find out? ;-) _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Not sure... but i''d start by inspecting it, using various different "classes"... for (var p in oMyInstance.constructor) { alert("p = " + oMyInstance[p]); } On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > Hmm, interesting. Frankly, i have no idea about the constructor thing -- > half expected it to throw an error. But I''m still not sure why you''re so > reluctanct to use the main prototype; this is what it''s for. Ultimately, > you''re looking for a way to use an instance to _get_at_ the main > prototype... so why not just do it directly? It''s a feature of the language, > man. > > test.prototype.color = ''purple''; > > I believe you are right. It took a little getting used to, so no problem, > and I''m glad to have had some confirmation of that approach in this thread. > > So... what does oMyInstance.contructor point to and how would I find out? > ;-) > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
typo... alert("p = " + oMyInstance.constructor[p]); On 6/21/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Not sure... but i''d start by inspecting it, using various different > "classes"... > > for (var p in oMyInstance.constructor) > { > alert("p = " + oMyInstance[p]); > } > > On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote: > > > Hmm, interesting. Frankly, i have no idea about the constructor thing > > -- half expected it to throw an error. But I''m still not sure why you''re so > > reluctanct to use the main prototype; this is what it''s for. Ultimately, > > you''re looking for a way to use an instance to _get_at_ the main > > prototype... so why not just do it directly? It''s a feature of the language, > > man. > > > > test.prototype.color = ''purple''; > > > > I believe you are right. It took a little getting used to, so no > > problem, and I''m glad to have had some confirmation of that approach in this > > thread. > > > > So... what does oMyInstance.contructor point to and how would I find > > out? ;-) > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
This may also help, http://lxr.mozilla.org/seamonkey/source/js/src/README.html On 6/21/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > typo... > > alert("p = " + oMyInstance.constructor[p]); > > On 6/21/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > Not sure... but i''d start by inspecting it, using various different > > "classes"... > > > > for (var p in oMyInstance.constructor) > > { > > alert("p = " + oMyInstance[p]); > > } > > > > On 6/21/06, Sam < sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hmm, interesting. Frankly, i have no idea about the constructor thing > > > -- half expected it to throw an error. But I''m still not sure why you''re so > > > reluctanct to use the main prototype; this is what it''s for. Ultimately, > > > you''re looking for a way to use an instance to _get_at_ the main > > > prototype... so why not just do it directly? It''s a feature of the language, > > > man. > > > > > > test.prototype.color = ''purple''; > > > > > > I believe you are right. It took a little getting used to, so no > > > problem, and I''m glad to have had some confirmation of that approach in this > > > thread. > > > > > > So... what does oMyInstance.contructor point to and how would I find > > > out? ;-) > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Jesse Kuhnert Tacos/Tapestry, team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
oops, caught another typo... alert(p + " = " + oMyInstance.constructor[p]); On 6/21/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > typo... > > alert("p = " + oMyInstance.constructor[p]); > > On 6/21/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > Not sure... but i''d start by inspecting it, using various different > > "classes"... > > > > for (var p in oMyInstance.constructor) > > { > > alert("p = " + oMyInstance[p]); > > } > > > > On 6/21/06, Sam < sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hmm, interesting. Frankly, i have no idea about the constructor thing > > > -- half expected it to throw an error. But I''m still not sure why you''re so > > > reluctanct to use the main prototype; this is what it''s for. Ultimately, > > > you''re looking for a way to use an instance to _get_at_ the main > > > prototype... so why not just do it directly? It''s a feature of the language, > > > man. > > > > > > test.prototype.color = ''purple''; > > > > > > I believe you are right. It took a little getting used to, so no > > > problem, and I''m glad to have had some confirmation of that approach in this > > > thread. > > > > > > So... what does oMyInstance.contructor point to and how would I find > > > out? ;-) > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Not sure... but i''d start by inspecting it, using various different "classes"... for (var p in oMyInstance.constructor) { alert("p = " + oMyInstance[p]); } Seems to point to nothing in Firefox anyway, the only property returned is: color=''purple''; <script type="text/javascript"> var test = function () {} test.prototype = {color: ''red''}; var oTest1 = new test(); var oTest2 = new test(); oTest2.__proto__.color = ''blue''; alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); test.prototype.color = ''green''; alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); oTest1.constructor.prototype.color = ''purple''; alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); for (var p in oTest1.constructor) { alert(p + " = " + oTest1.constructor[p]); // color=purple } _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Very interesting. It would seem the constructor points to a floating instance, not the actual prototype. I wonder what these 3 variations do... oTest1.constructor.color = ''purple''; oTest1.constructor.constructor.color = ''purple''; oTest1.constructor.constructor.prototype.color = ''purple''; On 6/21/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > Not sure... but i''d start by inspecting it, using various different > "classes"... > > for (var p in oMyInstance.constructor) > { > alert("p = " + oMyInstance[p]); > } > > Seems to point to nothing in Firefox anyway, the only property returned > is: color=''purple''; > > <script type="text/javascript"> > var test = function () {} > test.prototype = {color: ''red''}; > var oTest1 = new test(); > var oTest2 = new test(); > oTest2.__proto__.color = ''blue''; > alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); > test.prototype.color = ''green''; > alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); > oTest1.constructor.prototype.color = ''purple''; > alert(''oTest1:color='' + oTest1.color + '' oTest2:color='' + oTest2.color); > > > for (var p in oTest1.constructor) { > alert(p + " = " + oTest1.constructor[p]); // color=purple > } > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Nope... in fact this is one of the "dynamic" benefits of a prototype based > object system. Changing the prototype of the "class" function (the function > from which the other references are constructed), changes the state of all > instances automatically. > > MyObject.prototype.bSwitch = true; is the correct way to achieve what you > are looking for. Why would you want to do this by using an instance of said > class? It seems to me you''d _want_ to _not_ have to know what instances are > floating around in your application, so the "class" function''s prototype is > the natural place to make this change. In other words, you have 10 widgets > and a couple of flibbets, maybe a few woozles on your page, each of them > possibly containing N instances of MyObject. Why would you want to have to > know the name of one of those instances to set this switch across all of > them... see my point?Actually by MyObjec.bSwitch I was not refering to an instance but the the constructor. i.e. it''s a Class or Static member of the global MyObject object. The constructor of a class is an object too and can be referenced and have members You can still say var MyObject = Class.create(); MyObject.prototype = { ... other methods and properties } MyObject.bSwitch = false; obj1 = new MyObject(); obj2 = new MyObject(); But MyObject.bSwitch will be global.> > On 6/21/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''ve always though the ptototype objects are not mutable after > > instances have been made. I.e. changes to prototypes will not update > > existing instances. > > > > I''ve always done this: > > > > Object.extend(MyObject, {bSwitch: false}); > > > > then MyObjec.bSwitch can be set/got globally > > > > > > On 21/06/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I need a single boolean which would be "globally" accessible to all > > > instances of a class. Seems like the boolean should be in the class > > > prototype, but I was troubled by the difficulty of setting the prototype > > > boolean to true. Maybe I''m missing something? > > > > > > var MyObject = Class.create(); > > > > > > MyObject.prototype = { > > > bSwitch: false, > > > ... other methods and properties > > > } > > > > > > var oMyOb1 = new MyObject(); > > > var oMyOb2 = new MyObject(); > > > alert(oMyOb1.bSwitch); // reports false > > > alert(oMyOb2.bSwitch); // reports false > > > > > > Now set the value of bSwitch to true so all the oMyObN''s will see a true > > > value. > > > > > > I can see the following methods... > > > > > > // __proto__ works in Firefox/Safari but isn''t available in IE... > > > oMyOb1.__proto__.bSwitch = true; > > > > > > alert(oMyOb1.bSwitch); // reports true > > > alert(oMyOb2.bSwitch); // reports true > > > > > > // This changes bSwitch for a single instance. Not in the prototype. > > > oMyOb1.bSwitch = true; > > > > > > alert(oMyOb1.bSwitch); // reports true > > > alert(oMyOb2.bSwitch); // reports false, not what we want. > > > > > > // Seems strange to me to reference the Class, but this works... > > > MyObject.prototype.bSwitch = true; > > > alert(oMyOb1.bSwitch); // reports true > > > alert(oMyOb2.bSwitch); // reports true > > > > > > // It''s a little more satisfying to create a method to hide this > reference > > > to the class... > > > > > > MyObject.prototype = { > > > bSwitch: false, > > > setSwitch: function() {MyObject.prototype.bSwitch = true;} > > > } > > > // Now this works, and only requires a reference to a method on an > instance > > > oMyOb1.setSwitch(); > > > > > > alert(oMyOb1.bSwitch); // reports true > > > alert(oMyOb2.bSwitch); // reports true > > > > > > > > > // I thought all objects had prototypes. Why doesn''t this work? > > > oMyOb1.prototype.bSwitch = true; // error: oMyOb1 is not a function > > > Is there another method that I''ve missed? Did prototype.js extend > > > __proto__ to work in IE? > > > > > > Sam > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > -- > > Andrew Tetlaw > > htp://tetlaw.id.au > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Andrew Tetlaw htp://tetlaw.id.au
Back to Sam''s original question, according to this: http://www.stanford.edu/~newmanb/cs242_paper_deme.pdf An object prototype cannot be changed after instantiation and there''s not direct access for a programmer to an objects prototype. This would explain why MyObject.prototype.bSwitch = true works while oObject1.prototype.bSwitch = true doesn''t. It also explains the error message: MyObject is indeed a function and oObject is not. the only way to an objects prototype is via the constructor function. On 21/06/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> // I thought all objects had prototypes. Why doesn''t this work? > oMyOb1.prototype.bSwitch = true; // error: oMyOb1 is not a function > Is there another method that I''ve missed? Did prototype.js extend > __proto__ to work in IE? > > Sam-- Andrew Tetlaw htp://tetlaw.id.au
On 22/06/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> So... what does oMyInstance.contructor point to and how would I find out? > ;-)According to this page: http://www.mozilla.org/docs/dom/mozilla/protodoc.html oMyInstance.contructor points to the constructor function for the object instance But that Moz does not yet support using oMyInstance.contructor.prototype.[property] -- Andrew Tetlaw htp://tetlaw.id.au
On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> MyObject.prototype.bSwitch = true; is the correct way to achieve what you > are looking for.Personally I wouldn''t recommend doing this because of the potential for confusion. MyObject.prototype.bSwitch = true; is not exactly a class property because each instance can be changed individually. You can set it like this, sure MyObject.prototype.bSwitch = true and then oMyInstance1.bSwitch = true and oMyInstance2.bSwitch = true But if you then set oMyInstance1.bSwitch = false; it''ll only change it for the instance and not the class. Which means you are reading/setting in different ways leading to potential confusion/mistakes. -- Andrew Tetlaw htp://tetlaw.id.au
Right, but the original''s poster was looking for precisely a way to chance a property in the main function ("class") and have that change instantly propagate to all instances. On 6/21/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > MyObject.prototype.bSwitch = true; is the correct way to achieve what > you > > are looking for. > > Personally I wouldn''t recommend doing this because of the potential > for confusion. > > MyObject.prototype.bSwitch = true; is not exactly a class property > because each instance can be changed individually. > > You can set it like this, sure > MyObject.prototype.bSwitch = true > > and then oMyInstance1.bSwitch = true and oMyInstance2.bSwitch = true > > But if you then set oMyInstance1.bSwitch = false; it''ll only change it > for the instance and not the class. Which means you are > reading/setting in different ways leading to potential > confusion/mistakes. > > -- > Andrew Tetlaw > htp://tetlaw.id.au > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
lol, no ides why i decided "original" should be a possisive contraction. On 6/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Right, but the original''s poster was looking for precisely a way to chance > a property in the main function ("class") and have that change instantly > propagate to all instances. > > On 6/21/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > MyObject.prototype.bSwitch = true; is the correct way to achieve what > > you > > > are looking for. > > > > Personally I wouldn''t recommend doing this because of the potential > > for confusion. > > > > MyObject.prototype.bSwitch = true; is not exactly a class property > > because each instance can be changed individually. > > > > You can set it like this, sure > > MyObject.prototype.bSwitch = true > > > > and then oMyInstance1.bSwitch = true and oMyInstance2.bSwitch = true > > > > But if you then set oMyInstance1.bSwitch = false; it''ll only change it > > for the instance and not the class. Which means you are > > reading/setting in different ways leading to potential > > confusion/mistakes. > > > > -- > > Andrew Tetlaw > > htp://tetlaw.id.au > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
damnit... can''t type.. "possesive" On 6/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > lol, no ides why i decided "original" should be a possisive contraction. > > > On 6/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > Right, but the original''s poster was looking for precisely a way to > > chance a property in the main function ("class") and have that change > > instantly propagate to all instances. > > > > On 6/21/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > MyObject.prototype.bSwitch = true; is the correct way to achieve > > > what you > > > > are looking for. > > > > > > Personally I wouldn''t recommend doing this because of the potential > > > for confusion. > > > > > > MyObject.prototype.bSwitch = true; is not exactly a class property > > > because each instance can be changed individually. > > > > > > You can set it like this, sure > > > MyObject.prototype.bSwitch = true > > > > > > and then oMyInstance1.bSwitch = true and oMyInstance2.bSwitch = true > > > > > > But if you then set oMyInstance1.bSwitch = false; it''ll only change it > > > for the instance and not the class. Which means you are > > > reading/setting in different ways leading to potential > > > confusion/mistakes. > > > > > > -- > > > Andrew Tetlaw > > > htp://tetlaw.id.au > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Which is what I think he''s saying as well. You need to set it at a class level, not at the object level. Modifying the prototype will not modify all of the instances (according to Andrew, haven''t verified it or anything, but I think he''s right). So, if you set a class-level Boolean it should keep it''s state across all instances of that class. Or maybe I haven''t woken up yet :-) Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ryan Gahl Sent: Thursday, June 22, 2006 7:27 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Implementing a boolean "switch" in a Class Right, but the original''s poster was looking for precisely a way to chance a property in the main function ("class") and have that change instantly propagate to all instances. On 6/21/06, Andrew Tetlaw <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> MyObject.prototype.bSwitch = true; is the correct way to achieve whatyou> are looking for.Personally I wouldn''t recommend doing this because of the potential for confusion. MyObject.prototype.bSwitch = true; is not exactly a class property because each instance can be changed individually. You can set it like this, sure MyObject.prototype.bSwitch = true and then oMyInstance1.bSwitch = true and oMyInstance2.bSwitch = true But if you then set oMyInstance1.bSwitch = false; it''ll only change it for the instance and not the class. Which means you are reading/setting in different ways leading to potential confusion/mistakes. -- Andrew Tetlaw htp://tetlaw.id.au _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Ok... I''m not sure why there''s a semi-debate going on here... OP asked: "How can I set a value for a class such that all instances of said class get that value change automatically" I said "you have to change a property on the main class''s prototype... a la MyClass.prototype.bSwitch = true;" Yes, it gives rise to confusion later on and the OP will have to experience this for himself... but if that''s what he wants, that''s how to do it, and that _is_ what he asked how to do. On 6/22/06, Gregory Hill <Gregory_Hill-l9nu40+TWxQ@public.gmane.org> wrote:> > Which is what I think he''s saying as well. You need to set it at a class > level, not at the object level. Modifying the prototype will not modify all > of the instances (according to Andrew, haven''t verified it or anything, but > I think he''s right). So, if you set a class-level Boolean it should keep > it''s state across all instances of that class. Or maybe I haven''t woken up > yet J > > > > Greg > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Ryan Gahl > *Sent:* Thursday, June 22, 2006 7:27 AM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] Implementing a boolean "switch" in a Class > > > > Right, but the original''s poster was looking for precisely a way to chance > a property in the main function ("class") and have that change instantly > propagate to all instances. > > On 6/21/06, *Andrew Tetlaw* <atetlaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 21/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > MyObject.prototype.bSwitch = true; is the correct way to achieve what > you > > are looking for. > > Personally I wouldn''t recommend doing this because of the potential > for confusion. > > MyObject.prototype.bSwitch = true; is not exactly a class property > because each instance can be changed individually. > > You can set it like this, sure > MyObject.prototype.bSwitch = true > > and then oMyInstance1.bSwitch = true and oMyInstance2.bSwitch = true > > But if you then set oMyInstance1.bSwitch = false; it''ll only change it > for the instance and not the class. Which means you are > reading/setting in different ways leading to potential > confusion/mistakes. > > -- > Andrew Tetlaw > htp://tetlaw.id.au > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 23/06/06, Gregory Hill <Gregory_Hill-l9nu40+TWxQ@public.gmane.org> wrote:> Modifying the prototype will not modify all > of the instances (according to Andrew, haven''t verified it or anything, but > I think he''s right).Actually, Ryan is right. I did a test and If you modify a prototype object, existing instances of an object are updated. but you have to do it via the constructor function object not an instance. Which I think was confusing the original poster, Sam. But you cannot change an objects prototype to another prototype. here''s the test (using Firefox with firebug extension for the log): function obj(name) { this.name = name; } obj.prototype.p = "x"; obj.prototype.x = function(){ return this.p }; var obj1 = new obj(''1''); var obj2 = new obj(''2''); console.log(obj1.name + ":" + obj1.x()); console.log(obj2.name + ":" + obj2.x()); console.log("switch..."); obj.prototype.p = "kk"; console.log(obj1.name + ":" + obj1.x()); console.log(obj2.name + ":" + obj2.x()); the output: 1:x 2:x switch... 1:kk 2:kk -- Andrew Tetlaw htp://tetlaw.id.au
On 23/06/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok... I''m not sure why there''s a semi-debate going on here... >Not a debate, just cooperative exploration. :) -- Andrew Tetlaw htp://tetlaw.id.au