Array length: Difference between revisions

Content deleted Content added
Chikega (talk | contribs)
Chikega (talk | contribs)
Line 570:
END
</lang>
 
{{out}}
<pre> La longitud del array fruta$ es 2 </pre>
 
 
True BASIC's arrays are not fixed in length and, although True BASIC is a compiled-language, the number of elements can be changed during runtime using such functions as the MAT REDIM (matrix re-dimension) function. Although the starting index of 1 is in implicit, it can be changed by setting the lower and upper bounds (eg. fruit(0 to 3)) when declaring the array. Also, the example below uses the MAT READ function to read in the data elements into the array without having to explicitly list each variable-array index. The example also uses the SIZE function vs the bounds method to determine the length of the array. Finally, in this example the SIZE function was not assigned to a separate variable and instead is used within the PRINT function itself.
 
<lang basic>
DIM fruit$(2)
MAT READ fruit$
DATA "apple", "orange"
 
PRINT "The length of the array 'fruit$' is "; SIZE(fruit$)
END
</lang>
 
 
{{out}}
<pre> The length of the array 'fruit$' is 2 </pre>
 
=={{header|Batch File}}==