Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:01 03 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : does Basic run subscript expressions ?

Author Message
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 616
Posted: 11:39am 02 Nov 2025
Copy link to clipboard 
Print this post

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 States
Posts: 473
Posted: 12:16pm 02 Nov 2025
Copy link to clipboard 
Print this post

  zeitfest said  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..


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 Kingdom
Posts: 8256
Posted: 12:31pm 02 Nov 2025
Copy link to clipboard 
Print this post

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: Australia
Posts: 2796
Posted: 12:35pm 02 Nov 2025
Copy link to clipboard 
Print this post

> 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: Germany
Posts: 687
Posted: 01:25pm 02 Nov 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  Just be aware of the execution sequence. Sometimes you need brackets to force an expression to work in the way that you want. :)


You need inner brackets depending on math or logic to get the correct result.
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 616
Posted: 05:22pm 02 Nov 2025
Copy link to clipboard 
Print this post

Thanks  
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025