SUB SUB_EXAMPLE
(BYVAL passed
AS _OFFSET) 'this points to SUB EXAMPLE below, but uses an OFFSET to point to its parameter. 'NOTE: The sub/function name *MUST* be the same as QB64 translates it as, for us.
'General rule of thumb is to make the subname ALL CAPS, preceeded by SUB_ or FUNCTION_ as dictated.
TYPE DataType
'A datatype to use as an example
TYPE DataType2
'a second datatype
DIM m
AS _MEM 'A memblock to store some information m
= _MEMNEW(20) 'The proper size to fill the data type that we're interested in passing back to our program._MEMPUT m
, m.OFFSET
, "Hello World" '12 bytes
SUB_EXAMPLE m.OFFSET 'Call the sub with the offset to these 20 bytes of memory
SUB_EXAMPLE2 m.OFFSET 'Notice, we passed the same block of memory, but are handling it differently here,
' according to the paramters set in the second sub
SUB Example
(t
AS DataType
) 'And here, we want to set up the actual sub to work with our example datatype. PRINT t.x
'print the values of that memblock
SUB Example2
(x
AS DataType2
)