Rocket Terminal Emulator

 View Only

 How to pass a variable into a JavaScript script using bzsh.exe?

Eric Scherrer's profile image
Eric Scherrer posted 11-26-2021 19:16
I am using BlueZone 7.1 and need help passing variables into a JavaScript script.

Here is the script (LoadAccount.js):

var bzhao;

function Main(accountNumber) {
  bzhao = new ActiveXObject( "BZWhll.WhllObj" );
  bzhao.Connect( "A" );
  bzhao.SendKey( "<Home>" );
  bzhao.SendKey( accountNumber );
  bzhao.SendKey( "<Enter>" );
  bzhao.WaitReady( 10, 1 );
}

Main(accountNumber);

​
And here is how I am trying to call it:

c:\Program Files (x86)\BlueZone\7.1>bzsh.exe /a1234 /pC:\Temp\LoadAccount.js

And the error I am getting is "Script error at Line 12, Column 1: 'accountNumber' is undefined"

Is there a special name I need to use for my parameter or something like that?

Thanks




Zhi Li's profile image
ROCKETEER Zhi Li
First, to pass variable from bzsh command line to BlueZone script, /a parameter must be the last switch like this.

bzsh.exe /pC:\Temp\LoadAccount.js /a1234

Second, you need to call Command() to use the parameter value in the script, like this in your example.
Main(Command());​

Thanks
Eric Scherrer's profile image
Eric Scherrer
Thanks Zhi,

I moved the /a parameter to the end and changed main to Main(Command()); but still getting an error:

c:\Program Files (x86)\BlueZone\7.1>bzsh.exe /pC:\Temp\LoadAccount.js /a1234​

"Unable to open file C:\Temp\LoadAccount.js /a1234"

I noticed this isn't documented in the help until 10.1 but we are still on 7.1. It looks like it is treating the /a parameter as part of the file name. Could it be that our version does not support this?

Thanks,
Eric
Zhi Li's profile image
ROCKETEER Zhi Li
Yes, BlueZone has started to support /a parameter since 7.1.7. Please try 7.1.7 or above.
Eric Scherrer's profile image
Eric Scherrer
Thanks Zhi, I appreciate the guidance.