![]() |
What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? - 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: What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? (/showthread.php?tid=906) |
What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? - maeloterkim - 11-12-2019 Hi ![]() I didn't found the sintaxis for initialized data on 3D DIM array on this page https://zxbasic.readthedocs.io/en/latest/dim/ 2D is the only information If i want initialized data on a 3D DIM array or 4D , etc what is the sintaxis to do it? Thanks RE: What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? - Week of the agents - 11-13-2019 Same as for 2 DIM Array3D (3,2,1) AS ubyte => {{{{0,0}},{{0,0}},{{0,0}}},{{{0,0}},{{0,0}},{{0,0}}},{{{0,0}},{{0,0}},{{0,0}}},{{{0,0}},{{0,0}},{{0,0}}}} RE: What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? - maeloterkim - 11-14-2019 (11-13-2019, 08:43 PM)Week of the agents Wrote: Same as for 2 If i compile this with version-1.9.6 says : sintaxis-array-3D.bas:1: Mismatched vector size. Expected 2 elements, got 1. RE: What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? - boriel - 11-14-2019 You can use _ to break lines for better code legibilty. Also, when doing a DIM by default ZX Basic uses 0 index, o DIM a(3) contains FOUR slots a(0), a(1), a(2) and a(3). If you want to start form 1 like in Sinclair BASIC either compile with --array-base=1 or write it as this: DIM a(1 TO 3) That said, I guess you want: Code: DIM Array3D(1 TO 3, 1 TO 2, 1 TO 1) AS Ubyte => { _ Another way is to use DIM(3, 2, 1) and ignore the 0 position, but you have to initialize it anyway: Code: DIM Aarray3D(3, 2, 1) AS Ubyte => { _ Hope this helps. ![]() RE: What is the sintaxis for initialized 3D, 4d, etc DIM ARRAY ? - maeloterkim - 11-14-2019 (11-14-2019, 02:11 PM)boriel Wrote: You can use _ to break lines for better code legibilty. Thanks this is more clear and works great ![]() |