VBScript comparable to JS

Discussions concerning programming of SOFTIMAGE©
Post Reply
Falam

VBScript comparable to JS

Post by Falam » 14 Jun 2013, 17:29

VBScript

Code: Select all

Set oRoot = ActiveSceneRoot
set oObjs = oRoot.FindChildren()
for each i in oObjs
logmessage i
next
JScript

Code: Select all

var oRoot = ActiveSceneRoot
var oObjs = oRoot.FindChildren()
for (s=1;s<4=;s++){
LogMessage("oRoot")
}
All that is happening is the LogMessage command is looping 4x (JScript code).
Yet in the VBScript, things are completely different, what is the syntax difference ?

Edit: I want to squeeze in another question.
How can I offset objects in a loop. If I'm creating three primitives, and I want each one to have even spacing (JScript) ?

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 11:02
Location: Montreal Canada
Contact:

Re: VBScript comparable to JS

Post by xsisupport » 14 Jun 2013, 17:58

The JScript equivalent of your VBScript is...

Code: Select all

oEnum = new Enumerator( ActiveSceneRoot.FindChildren() ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
	var oSelItem = oEnum.item() ;
	LogMessage( oSelItem.fullname );
}
That's how you loop over the elements of a collection that you got from the XSI SDK (the JScript "for .. in" loop doesn't work on Softimage collections). In VBScript, however, you can use "for each".

In your JScript, you have a basic for loop that uses a counter variable.
Last edited by xsisupport on 14 Jun 2013, 19:45, edited 1 time in total.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: VBScript comparable to JS

Post by Hirazi Blue » 14 Jun 2013, 19:30

@Falam - As a general rule: don't try to learn
(or initially even try to understand)
several scripting languages at once.
Learning one can be tricky enough as it is.
:-?
Stay safe, sane & healthy!

Falam

Re: VBScript comparable to JS

Post by Falam » 14 Jun 2013, 20:13

I would never learn more then one at the same time, I don't think that is wise for anyone to do. You'll only confuse yourself, to such an extreme. I'm only learning JavaScript (&ICE), I know Python is the "grande" language to learn, but I like JScript syntax :)

Thanks Stephen. I didn't know about that command, I guess it comes with learning :)

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 01:41
Contact:

Re: VBScript comparable to JS

Post by EricTRocks » 16 Jun 2013, 23:53

FYI JScript is NOT Java Script.
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

Falam

Re: VBScript comparable to JS

Post by Falam » 17 Jun 2013, 05:03

EricTRocks wrote:FYI JScript is NOT Java Script.
JScript is a script language from Microsoft that is expressly designed for use within Web pages. It adheres to the ECMAScript standard and is basically Microsoft's equivalent to Netscape's earlier and more widely used JavaScript

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: VBScript comparable to JS

Post by Hirazi Blue » 17 Jun 2013, 10:13

The Wikipedia page for JScript goes one step further, quoting "JavaScript guru" Douglas Crockford:
[Microsoft] did not want to deal with Sun about the trademark issue, and so they called their implementation JScript. A lot of people think that JScript and JavaScript are different but similar languages. That's not the case. They are just different names for the same language, and the reason the names are different was to get around trademark issues.
(my highlight), but then goes on to say there are some differences in implementation...
8-}
Stay safe, sane & healthy!

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests