A little bit tricky are structures incorporating arrays.  In general, if
you just need a standalone array, then use a QB64 array, because these are
more easy to handle.  However, sometimes it is required to have an array
within a structure, because the structure content and the array content
depend on each other or have common belongings in general.

Example of usage: (a structure with array) ------------------------------------------ DefSTRUCTURE ArrStruct&, 0& DefULONG as_Counter& DefSTRUCT as_Array&, (10& * 4&) DefULONG as_WhatEver& DefLABEL ArrStruct_SizeOf& once again with explaination: ----------------------------- DefSTRUCTURE ArrStruct&, 0& 'init the structure, guess you know already how it works DefULONG as_Counter& 'an ULONG entry, eg. the number of used array elements DefSTRUCT as_Array&, (10& * 4&) 'now here you use DefSTRUCT to incorporate the size of the complete array 'as_Array& gets the current offset, which will be the base of the array for later access, 10& is the number of array elements and 4& the size of one single array element (here LONG) 'so in fact we created an array of 10 [0-9] LONG elements, defined as QB64 array you would write it DIM as_Array(9) AS LONG DefULONG as_WhatEver& 'another ULONG entry DefLABEL ArrStruct_SizeOf& 'finish the actual structure To access the array elements with the appropriate PokeXX and PeekXX routines (see memory.bm), I recommend adding the array's base offset to the structure address and using the element number multiplied with the element size as offset. For example, print all elements of the array defined above in a FOR..NEXT loop: 'assuming the structure address in ptr& FOR i& = 0 TO 9 PRINT PeekL&((ptr& + as_Array&), (i& * 4&)) NEXT i& However, you can of course find another way, as the addr& and offs& arguments of the PokeXX and PeekXX routines are generally interchangable. Back to Types Overview