SmallBASIC
SmallBASIC copied to clipboard
LEN seems linked to issue with array referencing
Hi, I'm enjoying SmallBASIC and wanted to share this issue in case it's relevant.
Version: SmallBasic FLTK 12.23, 7 Sep 2021 OS: Linux / AppImage
As an example, running the example here, an error is thrown:
https://smallbasic.github.io/pages/features.html
Code:
tload "/etc/passwd", buffer
for row in buffer
split row, ":", fields()
if (len(fields) > 0) then
local user
user.name = fields(0)
user.passwd = fields(1)
user.userId = fields(2)
user.groupId = fields(3)
users << user
fi
next row
? users
Error: RTE-ERROR AT untitled.bas:7 *
Description:
Array: Index '1' out of range. (Max = 1)
(Note: I changed the HTML codes for less-than, to << in the code to get it to work)
As a workaround, I changed LEN to UBOUND and the code worked fine.