![]() |
array bounds must be constant - 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: array bounds must be constant (/showthread.php?tid=314) |
array bounds must be constant - slenkar - 02-22-2011 How do I create an array with an integer instead of a literal number? I want to do this: Code: DIM personX (numPersons) as ubyte instead of: Code: DIM personX (6) as ubyte Re: array bounds must be constant - boriel - 02-22-2011 Unfortunately this is not (yet) supported. What you're asking is a DYNAMIC ARRAY. ![]() Code: CONST MaxPersons As Ubyte = 20 DYNAMIC Arrays are planned for the next release, please, be patient. Re: array bounds must be constant - slenkar - 02-22-2011 ah const, I didnt know we had that type thanks ![]() Re: array bounds must be constant - boriel - 02-22-2011 slenkar Wrote:ah const, I didnt know we had that type thanksYou can also use #define (like a C preprocessor): Code: #define MaxPersons 20 Code: #define MyFunc(x, y) \ Code: PRINT 3 * 2 + 1; Re: array bounds must be constant - slenkar - 02-22-2011 inline functions are cool too ![]() Re: array bounds must be constant - compiuter - 02-23-2011 Hi, Can I use #define functions in fastcalls or subs? Re: array bounds must be constant - boriel - 02-23-2011 compiuter Wrote:Hi, Can I use #define functions in fastcalls or subs?Yes; #define are just MACROS. Wherever you invoke them, they will be *replaced* with its definition. Re: array bounds must be constant - compiuter - 02-26-2011 macros functions created with #define can contain embebed asm or only basic? Re: array bounds must be constant - boriel - 02-26-2011 compiuter Wrote:macros functions created with #define can contain embebed asm or only basic?Whatever! Of course, if you must use ASM...END ASM to use macros. Remember also to end each line with \ or _ character (line break continue), to tell the compiler those lines are macro ones: Code: DIM a As Ubyte = 1 You can think of macros like inline SUBs. Update: errr... :oops: Just discovered the ASM inside the macro wasn't being correctly supported!. This bug has been fixed and now it works. Please download r2109 Re: array bounds must be constant - compiuter - 03-08-2011 Code: #define MyFunc(x, y) \ ![]() Re: array bounds must be constant - boriel - 03-08-2011 It works ok to me. :?: Which compiler version are you using? Download 1.2.7 or the latest devel, and try again... Re: array bounds must be constant - compiuter - 03-08-2011 Perhaps the version. I´ll take a look. |