redim_20preserve
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
redim_20preserve [2018/03/31 13:19] – external edit 127.0.0.1 | redim_20preserve [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
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 | ||
+ | </ | ||
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 | ||
+ | </ |
redim_20preserve.1522502377.txt.gz · Last modified: 2024/01/05 00:16 (external edit)