Asked
Resolved Resolved by DJ Sures!

Passing Variables Between Javascript And Ezscript.

Prior to ARC, I was able to pass variable among different scripts using EzScript.  I can still do that, but I cant pass a variable in JavaScript to and Ezscript.  is that something that can be implemented?


Related Hardware JD Humanoid

ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

PRO
Synthiam
#1  

getVar( variableName, [default value] ) Retrieves the value from the Arc’s global variable storage. These are variables that are published by skill controls, such as the Camera, Auto Position, Speech Recognition, etc..

{variableName} - The name of the global variable as a string {default value} [Optional] If specified, this value is returned if the global variable doesn’t exist. {return} The value of the global variable

Example: // Get the current direction the robot is moving var direction = getVar($Direction);

// Get the value of $test, and if it doesn’t exist return false var testVar = getVar($test, false);

setVar( variableName, value ) Sets the value from of Arc’s global variable storage. This allows the variable to be available to other controls or other scripts by using getVar().

{variableName} - The name of the global variable as a string {value} The value that you wish to store in the global variable {return} The value of the global variable

Example: // Set a value of 5 to be accessible by other controls setVar($MyValue, 5);

varExists( variableName ) Check if the global variable exists.

{variableName} - The name of the global variable as a string {return} true/false Boolean if the variable exists

Example: // print if the variable exists print(varExists($MyValue));

User-inserted image

PRO
USA
#2  

Dang it.  I didn't read that, as you've probably figured out.

So it worked, it set the variable, I can see it in the variable watcher.  But my ez script doesn't see that the variable has a value.  This script was wrote in a couple of versions before ARC.  Does that matter?

PRO
Synthiam
#3   — Edited

Perhaps you're trying to read the variable in EZ-Script before it is being set by Javascript. One exists only when one is existing:D yoda says

Javascript set the variable..


setVar("$myVariable", "this is text");

EZ-Script print the contents of the variable


print($myVariable)

PRO
USA
#4  

It was working all the time.  My old ezscript had an error and instead of halting, it just ran and did nothing.

but I found it and marked this resolved.

Thanks for the help, good night.

PRO
Synthiam
#5  

Anytime:) have a great night as well!