[Javascript] combining Javascript & VBscript
davecline at onebox.com
davecline at onebox.com
Thu Apr 1 00:30:31 CST 2004
JavaScript is so much more versatile than VBScript.
For instance...
Object creation:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
function createCurlyTestA(){
return {
id:"curlyTestA",
name:"Full Name of curlyTestA",
version: 1,
arrayTest:["arrayItem1","arrayItem2","arrayItem3"],
methods:{
"method1":{id:"method1",creationTime:new Date().getTime()},
"method2":{id:"method2",creationTime:new Date().getTime()},
"method3":{id:"method2",creationTime:new Date().getTime()}
}
}
}
Object inheritance:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
function bug(){
this.food=10;
this.eat = function(){this.food--;};
this.toString = function(){return "Food remaining:" + this.food;};
}
function beetle(){}
beetle.prototype = new bug();
beetle.eat()
alert(beetle.toString());
OR
var x
for (x in bug.prototype)
beetle.prototype=x;
And the way you can dynamically create new properties/function/objects from text...
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
This code take any XML file and turns it into a complete javascript object hierarchy.
as in:
<root>
<bugs>
<beetle name="barney" />
<ant name="arny" />
</bugs>
</root>
would become:
root.bugs[0].beetle.name = barney
root.bugs[1].ant.name = arny
http://www.bangeye.com/xtesting/XmlToJavaScriptObjects.html
It also transfers back a javascript hierarchy into an XML document.
All with JavaScript - very versatile.
--
Dave Cline
davecline at onebox.com
www.bangeye.com/
-----Original Message-----
From: Peter Brunone <peter at brunone.com>
Sent: Wed, 31 Mar 2004 22:20:53 -0600
To: "'[JavaScript List]'" <javascript at LaTech.edu>
Subject: RE: [Javascript] combining Javascript & VBscript
That's the nice thing about variants. If you suddenly assign it
to an array, it's an array, e.g.
myString = Split(myString, "|")
Convenient, but probably not the most efficient use of resources :-D
As for "freeing" string vars and such, you can set them equal to
Nothing; I don't know what the Javascript equivalent would be.
-----Original Message-----
From: javascript-bounces at LaTech.edu On Behalf Of David Lovering
I was thinking particularly of "freeing" a variable by deleting it,
although the other discussion is starting to turn out to be more
interesting. Also, I can think of a few bizarro situations where a
single variable might suddenly need to become an array, or vice-versa.
That's hard to do without a "new Array()" or something similar.
However, I'll defer to the other list readers. My peculiar interests in
pure OOL stuff does not (as yet) have any direct bearing on Javascript.
----- Original Message -----
From: "Chris T" <christ at saeweb.com>
> VBScript (and JavaScript) uses Variants though. So you don't have to
define
> variables as types. Why would there be a need to redefine it a second
time?
> Just set the variable if you want to change it's value type.
>
> Chris Tifer
>
> ----- Original Message -----
> From: "David Lovering" <dlovering at gazos.com>
>
> > Well, some might say that redefining a variable (either by value, or
> > by
> > type) might be useful, just as redefining an array might be. If
VBScript
> > doesn't support that in some fashion, I'd say it has a serious
> > problem.
> >
> > -- Dave Lovering
> >
> > ----- Original Message -----
> > From: "Paul Novitski" <paul at dandemutande.org>
> >
> > > One serious advantage VBscript has over Javascript is the
> > > enforcement
of
> > > unique variable names. Accidentally naming two variables the same
> > > can cause problems that are hair-pullingly difficult to detect &
> > > debug in
a
> > > complex application.
> > >
> > > Javascript blithely allows:
> > >
> > > var thingie = "a";
> > > var thingie = "b";
> > >
> > > whereas VB chokes on:
> > >
> > > dim thingie
> > > dim thingie
> > >
> > > and generates a runtime (compile) error "Name redefined".
> > >
> > > Alas, neither script seems to enforce uniqueness of function
> > > names,
> taking
> > > (in my experience) the last instance of a function as the one to
> > > run
> when
> > > it's called.
> > >
> > > Paul
> > >
> > > At 10:28 AM 3/30/2004, Chris T wrote:
> > > > > for example Javascript's string methods or, gosh, I don't
> > > > > know, maybe VBscript's high-level date & time formatting.
> > > >
> > > >That seems to be the biggest reason to want to do it. If you're
> > > >going straight VBScript, you will be limited in that you can't
> > > >get
> Milliseconds
> > > >I don't believe, but JS can do that.
> > > >
> > > >And like you said, the built-in formatting of dates is probably
> > > >superior in VBScript.
> > > >
> > > >Chris Tifer
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list