Jump to content
Macro Express Forums

External Script (JavaScript) will only take one external parameter set from Macro Express

Recommended Posts

I'm having trouble reading more than one parameter that I set in Macro Express and am brining into the external script Line Parameters. I'm using JavaScript.

My external parameters are:  %x%, %y%  (previously set in Macro Express as intergers although they get imported into the JS external script as strings)

In the external script (I selected JavaScript). 

xValue = WScript.Arguments(0);

yValue = WScript.Arguments(1);


I can read send either the xValue or the yValue to the Console back to Macro Express so I know they are importing.  

I convert them to numbers then try to attempt math (X+y) and export the total in a z variable through the console back to Macro Express.
When I get the -1.#IND error from the console in a pop-up I created in Macro Express.  

Note:  I've set all the variables to numbers.  I also got another error message that indicates the paramater wasn't big enough.


Any suggestions?


Link to comment
Share on other sites

I am speculating that you can't write to the console and get the value back. You need to use the Return function which terminates the script and writes the value to the console. That's what MEP reads in. 

Post an example of a script. Make is super simple and make sure it only contains commands that are needed to demonstrate the problem. 

  • Like 1
Link to comment
Share on other sites

We are moving to JavaScript so I need to convert my old codes to this program. 

In Macro Express I set 2 variables, for this example:  xInt = 3, and yInt = 4.   Set in Macro Express as Intergers

I Create an External Script (JScript) is the language.  Script Language Parameters line reads like this:  %xInt%, %yInt%

Save Console Output is:  %Output%


My Code within the External Script (JavaScript)


I've used 2 very simple codes - Neither one works.  I feel like I'm missing something.     Picture  .png attached.


JavaScript in Macro Express Error 2.26.21.png

Link to comment
Share on other sites


Note that you don't have to use parameters. 

BTW Kevin's example on the support page illustrates that only a space shoudl be between the values. I know this is the same in .NET and other languages and programs.

To be clear, if your value was 9 and you used that comma the JScript would receive a parameter "9," (numeral nine and a comma) which can only be used as text. I'm guessing what you did using the Number() function was to create an invalid cast exception. I don't have time to research it now, but what you saw returned "-1.#IND" is an exception code. I found this article for IEEE codes in C++ which look similar. I didn't read it, but it might be a clue for you here. 

You should use exception handling in your scripts and macros to avoid exceptions. 

  • Like 1
Link to comment
Share on other sites

The articles you provided will be helpful.  I appreciate the links and will refer back to them. 

Referring to your comment about Kevin's Support Page, "Have you checked out the sample on the ISS support page?"  I started there first, but Kevin didn't provide examples of passing variables/parameters so I thought the , (comma) was needed.   I use commas passing variables/parameters in the VBS External file and it works, so I assumed I needed commas on the JScript.  This error was totally missed by me.  


By removing the , (comma) between the variables it now works.  I will be passing multiple variables into the external script.  On any given day, I may pass numbers, strings like state names, and others will be patient account numbers to manipulate the data. 

Also to reduce code, I am grateful that you showed me in some instances I don't have to pass the parameters as the External Script will read them. This will be so helpful in some circumstances and will be easier to code!!  Love this!


All scenarios work.  This is my jobs staple program and I'm so grateful for your help.   We use this tool to save hours of repetitive processes/manpower and I'm grateful that the solution was so easy. 


  I love this site BTW.

No Comma and No Parameters works.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...