Forum > Android

byte array declaration bug in LAMW

(1/1)

neuro:
In Lazarus byte array can be declared in the following way:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  myArray: array of byte = ($41,$43,$45,$45,$49,$53,$55,$55,$5A,$61,$63,$65,$65,$69,$73,$75,$75,$7A);However LAMW fails to compile this code and throws error:

--- Quote ---Fatal: Syntax error, ";" expected but "ordinal const" found
--- End quote ---

The workaround solution for this LAMW bug is to declare byte array as:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  myArray: array [0..17] of byte = ($41,$43,$45,$45,$49,$53,$55,$55,$5A,$61,$63,$65,$65,$69,$73,$75,$75,$7A);
How to fix this byte array declaration bug in LAMW?

ojz0r:
Don't you always have to declare lenght of array [0..n]?

PascalDragon:

--- Quote from: neuro on July 15, 2021, 04:14:05 am ---However LAMW fails to compile this code and throws error:

--- Quote ---Fatal: Syntax error, ";" expected but "ordinal const" found
--- End quote ---

--- End quote ---

You need to use FPC 3.2.0 or newer. I don't know about LAMW, but at least for the FPC project 3.0.4 and older are no longer considered supported.

Navigation

[0] Message Index

Go to full version