This shows you the differences between two versions of the page.
en:dim [2016/08/12 21:37] admin |
en:dim [2020/02/28 10:46] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Dim (Statement) ===== | ||
- | |||
- | ==== Format ==== | ||
- | |||
- | === Create a One Dimensional Array === | ||
- | |||
- | **dim** [[variables|variable]] ( [[integerexpressions|array_size]] )\\ | ||
- | **dim** [[variables|variable]] ( [[integerexpressions|array_size]] ) **fill** [[expressions|expression]]\\ | ||
- | **dim** [[variables|variable]] [ [[integerexpressions|array_size]] ]\\ | ||
- | **dim** [[variables|variable]] [ [[integerexpressions|array_size]] ] **fill** [[expressions|expression]] | ||
- | === Create a Two Dimensional Array === | ||
- | |||
- | **dim** [[variables|variable]] ( //rows// , //columns// )\\ | ||
- | **dim** [[variables|variable]] ( //rows// , //columns// ) **fill** [[expressions|expression]]\\ | ||
- | **dim** [[variables|variable]] [ //rows// , //columns// ]\\ | ||
- | **dim** [[variables|variable]] [ //rows// , //columns// ] **fill** [[expressions|expression]] | ||
- | === Use a List to Create and Fill an Array === | ||
- | |||
- | **dim** [[variables|variable]] = [[Lists|{ list ... }]]\\ | ||
- | **dim** [[variables|variable]][] = [[Lists|{ list ... }]]\\ | ||
- | **dim** [[variables|variable]] = [[Lists|{ { list ... }, { list ... } ... }]]\\ | ||
- | **dim** [[variables|variable]][] = [[Lists|{ { list ... }, { list ... } ... }]] | ||
- | |||
- | === Copy One Array to Another === | ||
- | |||
- | **dim** [[variables|variable]] = [[variables|variable]]\\ | ||
- | **dim** [[variables|variable]][] = [[variables|variable]] | ||
- | |||
- | === Fill an Existing Array With a Single Value === | ||
- | |||
- | **dim** [[variables|variable]] **fill** [[expressions|expression]]\\ | ||
- | **dim** [[variables|variable]][] **fill** [[expressions|expression]] | ||
- | |||
- | ==== Description ==== | ||
- | |||
- | Returns a newly created single dimensional array of length //integer// or a 2 dimensional array that can be addressed by //row// and // | ||
- | |||
- | The first element of an array has an index of 0 (zero). | ||
- | |||
- | The **dim** statement can also be used to create a new array that is a duplicate of another array. | ||
- | |||
- | ==== Example ==== | ||
- | |||
- | < | ||
- | dim z = {1, 2, 3, 4, 5} | ||
- | print z[0] + " " + z[4] | ||
- | </ | ||
- | will print | ||
- | < | ||
- | 1 5 | ||
- | </ | ||
- | |||
- | ==== Example Two ==== | ||
- | < | ||
- | dim c(4) | ||
- | c[0] = " | ||
- | c[1] = " | ||
- | c[2] = " | ||
- | c[3] = " | ||
- | print c[2] + " " + c[3] + " "; | ||
- | print c[1] + " " + c[0] + "?" | ||
- | </ | ||
- | will print | ||
- | < | ||
- | how now brown cow? | ||
- | </ | ||
- | |||
- | ==== See Also ==== | ||
- | {{page> | ||
- | |||
- | ==== History ==== | ||
- | |1.99.99.55|Cleaned up documentation and added array copy.| | ||
- | |1.99.99.56|Added fill clause| | ||
- | |1.99.99.57|Added additional fill options| | ||