Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with associative array example #148

Open
circular opened this issue Jun 12, 2022 · 2 comments
Open

Issue with associative array example #148

circular opened this issue Jun 12, 2022 · 2 comments

Comments

@circular
Copy link

I was just learning about associative arrays in SmallBASIC and unfortunately there seems to be an issue with the exmaple:

https://smallbasic.github.io/pages/features.html

tload "/etc/passwd", buffer
dim users
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)
    ' Line below seems linked to error
    users(user.name) = user
  fi
next row
? users("mail").userId
RTE-ERROR ... Line 11
Expr/RT: Not a number
@Joe7M
Copy link
Contributor

Joe7M commented Oct 19, 2022

I just realized, when doing 2 changes, the example works. But still DIM doesn't do, what it should.

tload "/etc/passwd", buffer
users = array("{}")
for row in buffer
  split row, ":", fields()
  if (ubound(fields) > 0) then
    local user
    user.name = fields(0)
    user.passwd = fields(1)
    user.userId = fields(2)
    user.groupId = fields(3)
    ' Line below seems linked to error
    users(user.name) = user
  fi
next row
? users("mail").userId

@Joe7M
Copy link
Contributor

Joe7M commented Dec 13, 2022

I forgot to mention, that I fixed the example a while ago -> Update example according to bug #148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants