Compiler Error warning: "There's a problem with your code: Invalid Octal number "

I am working on an imp006.
I am transferring coil and holding register data over modbus rtu from a slave device.
I am working on transitioning data from a modbus read call data to an array.
I was aiming at migrating data from the read when I found an interesting compiler error warning.
I found from the declared arrays for this data handling that all were flagged for Octal number form array indexes of 0000-0800. After array position 800, there is no complaint.
My questions are: Are all Array data types in Octal? It there something special about the index 0000-0800 that needs to be Octal or Is the entire array Octal and the Compiler lazy and quits after 0800?
I have not finished my data validation to prove it one way of another. I am wondering if anyone knows the answer. I have not found any literature specifying this one way or another.

Just an update… Array[0000] → Array[0799] will return “There is a problem with your code: Invalid octal number” because the leading zero triggers the dynamic addressing to think it is octal addressing. It is still unclear why the error stops at Index 0799. index 0800 ->0999 are recognized as decimal numbers.

What you’ve discovered is definitely true (and has been across all improm versions) but you’re quite right that it’s a bit surprising and, frankly, odd.

In Squirrel source code, integer literals starting 00 - 07 parse as octal (meaning that 010 parses as the integer 8, and “019” throws an error). Integer literals starting 08, 09, or 1 - 9 parse as decimal. (Integer literals starting 0x parse as hex.)

This is inexplicably different from the operation of the string.tointeger() method, which only ever parses as hex or decimal, never octal.

It is unlikely that we can improve any of this, as it would change the meaning of existing programs.

Peter

This topic was automatically closed after 60 days. New replies are no longer allowed.