jeffdoo
Intermediate
Intermediate
Posts: 334
Joined: Sat Aug 25, 2007 10:19 pm
Location: Huntersville, NC
Contact: Send private message

JScript Example(s)?

Wed Jan 14, 2009 10:08 pm

The subject says it all...

Does anyone have an example using JScript? Or the two existing VBScript examples but written in JScript?

I have no idea how to call the MLServer object or even create an instance because MLServer "is undefined" and I've tried a variety of case combinations. Figured it's simpler to just ask and hope someone has a couple nice simple examples.

Thanks!

User avatar
AllonisDave
Founder
Founder
Posts: 11604
Joined: Fri Feb 07, 2003 8:56 am
Location: Newport Beach, CA
Contact: Send private message

Sun Jan 18, 2009 5:09 pm

First upgrade to MLScript 3.0.11. I added the ability to dynamically switch between VBScript and JScript.

Here is the Sample1 script converted to JScript as an example.

Code: Select all

function MySample() { var oShell = new ActiveXObject("WScript.Shell"); var Username = oShell.ExpandEnvironmentStrings("%username%"); var MyServer = MLServer.GetVariable ("server_servername"); oShell.Popup (MyServer); var MyIPAddr = MLServer.GetVariable ("server_ipaddress"); oShell.Popup (MyIPAddr); var tmpStr = "Hello " + Username + " your server name is " + MyServer + " and its IP Address is " + MyIPAddr; oShell.Popup (tmpStr); MLServer.SetVariable ("AAATest", tmpStr); } MySample();

jeffdoo
Intermediate
Intermediate
Posts: 334
Joined: Sat Aug 25, 2007 10:19 pm
Location: Huntersville, NC
Contact: Send private message

Sun Jan 18, 2009 5:53 pm

Dave,

Sorry to keep you hopping on a Sunday.... MuL and now MLScript...

I have confirmed with the new .11 version everything is now working as expected!

Thanks!

- Jeff

jeffdoo
Intermediate
Intermediate
Posts: 334
Joined: Sat Aug 25, 2007 10:19 pm
Location: Huntersville, NC
Contact: Send private message

Mon Jan 19, 2009 8:04 pm

Dave,

I give up... can you show an example passing parameters?!?!

I've confirmed the above example works and did a rough pass at a basic script, so now it's time to pass in some variables. But, no matter what I try I cannot reference WScript.Arguments which I assume is the proper way to get the variables being passed.

Thanks

- Jeff

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 1:19 pm
Contact: Send private message

Re: JScript Example(s)?

Mon Nov 15, 2010 1:48 am

Did anyone get this working with jScript.

I can't get parameters passed in either. It works fine otherwise (if I hardcode teh values). It defintely doesn't work like vbscript. I would assume it called with the parameter as an array, but that never happens.

User avatar
AllonisDave
Founder
Founder
Posts: 11604
Joined: Fri Feb 07, 2003 8:56 am
Location: Newport Beach, CA
Contact: Send private message

Re: JScript Example(s)?

Tue Nov 16, 2010 11:43 am

Why do you have to write the script in JScript? Everything you can do with JScript you can do with VBScript. The MSDN site has a good primer on JScript and its syntax varies widely away from standard Javascript and of course VBScript. Use VBScript instead.

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 1:19 pm
Contact: Send private message

Re: JScript Example(s)?

Tue Nov 16, 2010 12:52 pm

Well, I don't have to and I ended up re-writing it to vbscript yesterday. I already had it working in javascript for where I used this call to the universal devices ISY box somewhere else and wanted to just maintain 1 version of the code.

I don't need a VBScript primer or Jscript or Javascript, BUT I guess what you are saying is that MLScript doesn't support parameter passing in JScript.

It might help if you just state that or provide an example so it is here for anyone to find if they do start down the path of using JScript.

I'll just assume it doesn't support parameter passing in JScript.

User avatar
AllonisDave
Founder
Founder
Posts: 11604
Joined: Fri Feb 07, 2003 8:56 am
Location: Newport Beach, CA
Contact: Send private message

Re: JScript Example(s)?

Tue Nov 16, 2010 12:59 pm

It does support passing parameters. I had an example of it once but I couldn't find it. I found how to do it on the MSDN site. Hence my reference to it.

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 1:19 pm
Contact: Send private message

Re: JScript Example(s)?

Tue Nov 16, 2010 6:46 pm

I tried every way I could find online and couldn't get to the object. There is something there, but it is not an array or a generic object and I can't debug it so I gave up

Return to “MLScript”

Who is online

Users browsing this forum: No registered users and 1 guest