Is there any way to create a DIM with variables? - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: Is there any way to create a DIM with variables? (/showthread.php?tid=881) |
Is there any way to create a DIM with variables? - maeloterkim - 06-04-2019 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 Re: Is there any way to create a DIM with variables? - boriel - 06-04-2019 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. Re: Is there any way to create a DIM with variables? - maeloterkim - 06-04-2019 Thanks Well i was not asking for something complicated Now i "resolved this" by doing a #DEFINE Not is a variable, but for the purpose of the problem is good enough i made this per example #DEFINE SOMENAME 20 DIM variableName( 20 * (SOMENAME + 1 ) ) AS UBYTE This works enoug for me Re: Is there any way to create a DIM with variables? - boriel - 06-04-2019 Well, you can also use CONST to define a value, and use them in an array definition Code: const cols as Uinteger = 32 Rows and cols cannot change. They're constants. So this is allowed. 8) |