User Tools

Site Tools


en:dim

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:dim [2016/01/01 22:40]
127.0.0.1 external edit
en:dim [2020/02/28 10:46] (current)
Line 3: Line 3:
 ==== Format ==== ==== Format ====
  
-**dim** //numeric_variable// //posint_expr// )\\ +=== Create a One Dimensional Array === 
-**dim** //string_variable$// //posint_expr// )\\ + 
-**dim** //numeric_variable// //posint_expr// //posint_expr// )\\ +**dim** [[variables|variable]] [[integerexpressions|array_size]] )\\ 
-**dim** //string_variable$// //posint_expr// //posint_expr// )+**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]]  [[integerexpressions|array_size_rows]] [[integerexpressions|array_size_columns]])\\ 
 +**dim** [[variables|variable]]  [[integerexpressions|array_size_rows]] [[integerexpressions|array_size_columns]]**fill** [[expressions|expression]]\\ 
 +**dim** [[variables|variable]] [  [[integerexpressions|array_size_rows]] , [[integerexpressions|array_size_columns]]]\\ 
 +**dim** [[variables|variable]] [  [[integerexpressions|array_size_rows]] , [[integerexpressions|array_size_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 ==== ==== Description ====
  
-Returns a newly created single dimensional array of length //integer// or a 2 dimensional array thst can be addressed by //row// and //column//Depending on the variable assignment, a string or numerical array is created.\\+Returns a newly created single dimensional array of length //integer// or a 2 dimensional array that can be addressed by //row// and //column// By default the elements in the array are left uninitialized (empty)You may add the fill option to fill all elements with single value.\\ 
 The first element of an array has an index of 0 (zero).  Indexes range from 0 to length-1. The first element of an array has an index of 0 (zero).  Indexes range from 0 to length-1.
 +
 +The **dim** statement can also be used to create a new array that is a duplicate of another array.  The form "DIM var = var" does this by dimensioning a new array in memory and copying all of the data from the original array.
  
 ==== Example ==== ==== Example ====
  
 <code> <code>
-dim z(5) +dim z = {1, 2, 3, 4, 5}
-z = {1, 2, 3, 4, 5}+
 print z[0] + " " + z[4] print z[0] + " " + z[4]
 </code> </code>
Line 27: Line 53:
 ==== Example Two ==== ==== Example Two ====
 <code> <code>
-dim c$(4) +dim c(4) 
-c{"cow""brow""how""now"} +c[0] = "cow" 
-print c$[2] + " " + c$[3] + " "; +c[1] = "brown" 
-print c$[1] + " " + c$[0] + "?"+c[2] = "how" 
 +c[3] = "now" 
 +print c[2] + " " + c[3] + " "; 
 +print c[1] + " " + c[0] + "?"
 </code> </code>
 will print will print
Line 40: Line 69:
 {{page>en:start#Arrays and Variables&noheader}} {{page>en:start#Arrays and Variables&noheader}}
  
 +==== 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|
 +|1.99.99.72|added the [] when setting one array from another|
  
en/dim.1451713251.txt.gz · Last modified: 2020/02/28 10:46 (external edit)