allocating_20arrays_20using_20the_20windows_20api
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
allocating_20arrays_20using_20the_20windows_20api [2018/04/17 15:01] – Added syntax highlighting tbest3112 | allocating_20arrays_20using_20the_20windows_20api [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====Allocating arrays using the Windows API===== | + | =====Allocating arrays using the Windows |
//by Richard Russell, December 2006//\\ \\ You can allocate arrays, using **DIM**, either on BASIC' | //by Richard Russell, December 2006//\\ \\ You can allocate arrays, using **DIM**, either on BASIC' | ||
Line 28: | Line 28: | ||
- Destroy first array | - Destroy first array | ||
- Destroy second array | - Destroy second array | ||
- | \\ Because LOCAL arrays are allocated on the //stack// they can only be destroyed in the reverse order from which they were created.\\ \\ In these cases it is possible to utilise the capabilities of the **Windows API** to allocate and free the memory used by arrays. By setting BASIC' | + | \\ Because LOCAL arrays are allocated on the //stack// they can only be destroyed in the reverse order from which they were created.\\ \\ In these cases it is possible to utilise the capabilities of the **Windows |
+ | |||
+ | **BBC BASIC for Windows:** | ||
<code bb4w> | <code bb4w> | ||
DEF PROCdim1d(RETURN A(),S%,D1%) | DEF PROCdim1d(RETURN A(),S%,D1%) | ||
Line 49: | Line 51: | ||
ENDPROC | ENDPROC | ||
</ | </ | ||
+ | |||
+ | **BBC BASIC for SDL 2.0:** | ||
+ | <code bb4w> | ||
+ | DEF PROCdim1d(RETURN A(),S%,D1%) | ||
+ | LOCAL a%% | ||
+ | SYS " | ||
+ | IF @platform% AND &40 ELSE a%% = !^a%% | ||
+ | ?a%%=1 : a%%!1=D1%+1 | ||
+ | PTR(A()) = a%% | ||
+ | ENDPROC | ||
+ | |||
+ | DEF PROCdim2d(RETURN A(), | ||
+ | LOCAL a%% | ||
+ | SYS " | ||
+ | IF @platform% AND &40 ELSE a%% = !^a%% | ||
+ | ?a%%=2 : a%%!1=D1%+1 : a%%!5=D2%+1 | ||
+ | PTR(A()) = a%% | ||
+ | ENDPROC | ||
+ | |||
+ | DEF PROCundim(RETURN A()) | ||
+ | SYS " | ||
+ | PTR(A()) = 0 | ||
+ | ENDPROC | ||
+ | </ | ||
+ | |||
In each case the parameters supplied to the **PROCdim** procedure are the name of the array to be created, the size (in bytes) of each array element and the array' | In each case the parameters supplied to the **PROCdim** procedure are the name of the array to be created, the size (in bytes) of each array element and the array' | ||
allocating_20arrays_20using_20the_20windows_20api.1523977311.txt.gz · Last modified: 2024/01/05 00:18 (external edit)