Migrating from EZ-Script to JavaScript

Organized Commands

JavaScript organizes commands in groups, called classes. There are classes for controlling servos, reading ADC, setting and reading digital ports, and more. The methods within the classes are well documented on the JavaScript manual page in the support section.

ARC JavaScript Manual: https://synthiam.com/Support/javascript-api/javascript-overview

How Does It Work

When typing in the JavaScript window, intellisense will detect the first characters of each word and display a dropdown of options. For example, if want to move a servo into a position, we begin typing Servo. and the class for servo commands will display.

User-inserted image

Each class separates the commands by a (.) period. Select the class and the commands within that class will be displayed.

User-inserted image

And here we can see the command Servo.setServoPosition, to move a servo into a specified position. There are variants of the command that support different parameters. That means you can type any variant of that command by providing only the parameters that you wish to provide. For Servo.setServoPosition, there is one variant that accepts the board index, and the other does not which means it defaults to index #0

Either of these two servo commands will perform the same outcome. The only difference is the second command is specifying the EZB board index.

Servo.setPosition(d0, 75);

Servo.setPosition(d0, 75, 0);

ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

#1  

Wow that is totally great info to know, thanks!

#2  

Thanks for this Tutorial @DJ. It will be invaluable as I change over my many scripts from EZ Script to JavaScript! I'm excited to see how my robot's arm servo react to the new faster language. I have some pretty complex scripts (for me anyway. LOL).

PRO
Synthiam
#3  

I think you'll find that the new scripts you write will be even smaller and faster. Probably easier to read as well. I can always help you change some over if you post one. That'll give you examples of how the difference would be.

#4   — Edited

But just to be clear, the EZ scripts should still mostly work in Arc? I tried 2 that still worked no conversion. Just slower most likely.

PRO
Synthiam
#5  

Yeah, EZ-Script works in ARC. This is a tutorial to help people migrate to a faster and more feature-rich language.

#6  

Wow @DJ. That's an amazing offer. Thanks! I'll post one soon. I think I have covid now and need to get past that first. Can't quite thing straight right now. LOL.

PRO
Synthiam
#7  

Oh boy, it seems everyone is getting covid these days. I'm feeling left out. I hope you're doing well and binge-watching a lot of tv! Drink soup and dream about robots.

#8  

Thanks DJ. I'm coming to the end of it I hope. Feeling better. Don't feel left out. Only good thing about this is now I have some antibodies for a while. LOL. Stay healthy!