PB Version 4.51
TB Version 1.4.7
From TB documentation.
TestTailbite.pbYou can use arrays, linked lists, global/shared/protected variables, structures, interfaces, etc., and every function or feature PureBasic provides, as long as you use them inside your Procedure's and ProcedureDLL's. But you can, of course, make enumerations and interface, structure, global and procedure declarations outside. Any other code outside procedures will be ignored, except for DataSection's and the Data's, IncludeBinary's and labels inside them. IncludeFile is also allowable outside the procedure, of course, because the compiler processes it before creating the 'PureBasic.asm' file.
Code: Select all
Structure XYZ
X.l
Y.l
Z.l
EndStructure
Global NewList tbl.XYZ() ; declared here creates an error. Invalid memory access.
ProcedureDLL TestTailbite_Init()
; Some examples use this method.
; Global NewList tbl.XYZ() ; declared here no errors but returns 0.
EndProcedure
ProcedureDLL TestTailbite_End()
EndProcedure
Procedure testlink()
AddElement(tbl()) ; <----- ERROR HERE!
tbl()\X = Random(100)
tbl()\Y = Random(100)
tbl()\Z = tbl()\X + tbl()\Y
ProcedureReturn tbl()\Z
EndProcedure
ProcedureDLL hitlink()
ProcedureReturn testlink()
EndProcedure
Procedure showlink()
Protected value
ResetList(tbl())
ForEach tbl()
value + 1
MessageRequester(Str(value), Str(tbl()\Z))
Next
ProcedureReturn value
EndProcedure
ProcedureDLL hotlink()
ProcedureReturn showlink()
EndProcedure
; Local Test passed.
;Debug hitlink()
;Debug hotlink()
Example1.pb
Code: Select all
a = hitlink()
Debug a