Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:52 19 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 : CMM2: Define range of array

Author Message
bar1010
Senior Member

Joined: 10/08/2020
Location: United States
Posts: 197
Posted: 11:36pm 12 Jun 2021
Copy link to clipboard 
Print this post

Is there a way to define the range of an array such as
dim integer array1(-10 to 10) or dim integer array2(12 to 24)?
If not, could this functionality be added?
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 535
Posted: 04:01am 13 Jun 2021
Copy link to clipboard 
Print this post

Maybe you can use an auxiliary variable as an offset



' For array1(-10 to 10)
dim integer array1(20), a1_offset=10

array1(a1_offset + -10) = 100
array1(a1_offset +  -9) = 101
...
array1(a1_offset +  10) = 120



' For array2(12 to 24)
dim integer array2(12), a2_offset=-12

array2(a2_offset + 12) = 0
array2(a2_offset + 13) = 1
...
array2(a2_offset + 24) = 23


Edited 2021-06-13 17:05 by LeoNicolas
 
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