Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there any way to create a DIM with variables?
#1
Hi

I'm trying this

DIM variableName( 20 * ( myVariable + 1 ) ) AS UBYTE

but the compiler says : "Array bounds muts be constants"

Is there any way to create a DIM with variables?

With a Basic variable?

Thanks
Reply
#2
Unfortunately not yet. These are DYNAMIC variables. I'm currently working on that feature. :roll:
You can, however do a "dirty trick" of allocating a dynamic block of memory (with alloc) and then use PEEK / POKE on top of it (similar to a C ptr).
I will post then it's ready.
Reply
#3
Thanks

Well i was not asking for something complicated Smile

Now i "resolved this" by doing a #DEFINE

Not is a variable, but for the purpose of the problem is good enough Smile

i made this per example

#DEFINE SOMENAME 20

DIM variableName( 20 * (SOMENAME + 1 ) ) AS UBYTE

This works enoug for me Smile
Reply
#4
Well, you can also use CONST to define a value, and use them in an array definition

Code:
const cols as Uinteger = 32
const rows as Uinteger = 24
dim a(rows, cols) as Uinteger

Rows and cols cannot change. They're constants. So this is allowed. 8)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)