PScript – Part 5 – Arrays

uint8 myArray[50]

The statement above is an array of 50 bytes. The first element is 0 while the last is 49.

uint8 myArray[1..50]

This is the same array of 50 elements, but now with the first element as 1 and the last as 50.

foreach uint8 x through myArray

The foreach statement above will iterate through the array with x increasing. I will look into using “in” rather than “through”, meaning that x is the variable rather than the index, but I believe the through concept is easier to implement and more powerfully as it sometimes are needed to know if your the first or last entry.

I also need functions to return start-index, end-index and length of an array. In addition we need more dimensions:

uint8 myArray[50][50]...

It is a few things I want to add, but I also need to weight that against the size of the PScript package.

Leave a Reply