|
Forum Index : Microcontroller and PC projects : does Basic run subscript expressions ?
| Author | Message | ||||
| zeitfest Guru Joined: 31/07/2019 Location: AustraliaPosts: 616 |
Just wondering, does Basic accept subscript expressions ? Eg where gunge is an array foo = gunge(6*j+2) To me they seemed to be best avoided but they were in use to some extent. I am wondering whether to add the capability to my interpreter (mainly as a result of a boredom tsunami )then again it should also handle COMMON named blocks, adding them would probably be pointless but hey.. |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 473 |
Yes, you can certainly use expressions rather than a numeric constant as an index. It's a major benefit of arrays. |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8256 |
Just be aware of the execution sequence. Sometimes you need brackets to force an expression to work in the way that you want. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2796 |
> dim foo, gunge(11), j > for n=0 to 11 :gunge(n)=n :next > j=0 : foo = gunge(6*j+2) :? foo 2 > j=1 : foo = gunge(6*j+2) :? foo 8 > |
||||
| dddns Guru Joined: 20/09/2024 Location: GermanyPosts: 687 |
You need inner brackets depending on math or logic to get the correct result. |
||||
| zeitfest Guru Joined: 31/07/2019 Location: AustraliaPosts: 616 |
Thanks |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |