![]() |
|
Is there any way to create a DIM with variables? - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://forum.boriel.com/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 - 2019-06-04 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 - 2019-06-04 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 - 2019-06-04 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 - 2019-06-04 Well, you can also use CONST to define a value, and use them in an array definition Code: const cols as Uinteger = 32Rows and cols cannot change. They're constants. So this is allowed. 8) |