Migrating from EZ-Script to JavaScript
For Loop
EZ-Script has a few different methods to loop. You can loop with EZ-Script using the REPEAT, REPEATUNTIL, REPEATWHILE, and simple GOTO. We'll cover the equivalent JavaScript commands here.
REPEAT = FOR
The EZ-Script REPEAT command is equivalent to the FOR command in JavaScript.EZ-Script
REPEAT($cnt, 1, 10, 1)
print($cnt)
ENDREPEAT
JavaScript
for (var cnt = 0; cnt < 10; cnt++) {
print(cnt)
}
Here is an explanation of each command in the FOR statement from the W3 Schools website.
Statement 1 is executed (one time) before executing the code block. Statement 2 defines the condition for executing the code block. Statement 3 is executed (every time) after the code block has been executed.Quote:
for (statement 1; statement 2; statement 3) { // code block to be executed }
REPEATWHILE = WHILE
The EZ-Script REPEATWHILE() command is replaced with WHILE() in JavaScript. They operate the same way and accept the same parameter. The loop will continue while the condition is TRUE.EZ-Script
$cnt = 0
repeatwhile( $cnt < 5)
print($cnt)
$cnt = $cnt + 1
endrepeatwhile
JavaScript
var cnt = 0;
while (cnt < 5) {
print(cnt);
cnt = cnt + 1;
}
Wow that is totally great info to know, thanks!
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).
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.
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.
Yeah, EZ-Script works in ARC. This is a tutorial to help people migrate to a faster and more feature-rich language.
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.
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.
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!