User Tools

Site Tools


redim_20preserve

Differences

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

Link to this comparison view

redim_20preserve [2018/03/31 13:19]
127.0.0.1 external edit
redim_20preserve [2018/04/17 18:31] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, May 2014//\\ \\  Liberty BASIC does not have the REDIM PRESERVE statement, available in some other BASIC dialects, which is used to change the dimensions of an array without destroying the data it contains. Fortunately in **LB Booster** it is possible to simulate this statement by means of a user-defined subroutine:​\\ ​ //by Richard Russell, May 2014//\\ \\  Liberty BASIC does not have the REDIM PRESERVE statement, available in some other BASIC dialects, which is used to change the dimensions of an array without destroying the data it contains. Fortunately in **LB Booster** it is possible to simulate this statement by means of a user-defined subroutine:​\\ ​
 +<code lb>
   SUB RedimPreserve BYREF A(), newsize   SUB RedimPreserve BYREF A(), newsize
       !N% = 5+10*(newsize+1)       !N% = 5+10*(newsize+1)
Line 25: Line 26:
       !!^A$() = A%       !!^A$() = A%
   END SUB   END SUB
 +</​code>​
 The first routine listed is suitable for use with a 1-dimensional numeric array and the second with a 1-dimensional string array. Note that the routines consist of BBC BASIC code, hence the presence of an exclamation mark (**!**) at the start of each line to force the LBB translator to pass the code unmodified.\\ \\  Here is an example program:​\\ ​ The first routine listed is suitable for use with a 1-dimensional numeric array and the second with a 1-dimensional string array. Note that the routines consist of BBC BASIC code, hence the presence of an exclamation mark (**!**) at the start of each line to force the LBB translator to pass the code unmodified.\\ \\  Here is an example program:​\\ ​
 +<code lb>
       DIM array(100)       DIM array(100)
       FOR i = 0 TO 100       FOR i = 0 TO 100
Line 51: Line 54:
       !!^A() = A%       !!^A() = A%
   END SUB   END SUB
 +</​code>​
redim_20preserve.txt ยท Last modified: 2018/04/17 18:31 by tbest3112