Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationFor to loops

Official ZPE/YASS documentationFor to loops

As well as the standard for loop, YASS also supports an alternative syntax, similar to VB.NET, that uses the to keyword:

YASS
for($i = 0 to 10)
  //Do something
end for
  

As with all loops, for loops may be terminated by end loop.

Performance differences

In reality, the YASS for to loop is considerably higher performance compared with the C-style version, especially when using a native build of ZPE. This is because unlike the standard C-style for loop, the for...to loop will not perform any checking of conditions on each iteration.

ZPE 1.12.4+

ZPE 1.12.4 onwards also support evaluatable expressions in both parts of the loop:

YASS
for($i = 0 to $x + 3)
  //Do something
end for
  
YASS
for($i = 0 to count($x) - 1)
  //Do something
end for
  
Comments
Feedback 👍
Comments are sent via email to me.