Kommentare inliegend.
Code: Alles auswählen
EnableExplicit
Global Dim StructAbfrage(0)
;P_Struct brauchst du für gar nix. Die Structures 'S_Box' und 'S_Ball' sind sowieso immer da.
Procedure P_Struct()
Structure S_Box
TestBox.i
EndStructure
Structure S_Ball
TestBall.i
EndStructure
EndProcedure
Procedure P_Create_MyBox(index)
;Wieso MeshID fest auf 1 setzen? Das macht doch keinen Sinn. Dann kannst du doch auch gleich überall dafür 1 einsetzen.
Protected MeshID = 1
;Wenn du zuerst P_Create_MyBall() aufrufst, dann P_Create_MyBox() und dann wieder P_Create_MyBall(), dann
;ist der erste erstellte Ball wieder weg, weil dann unten Global Dim S_Ball.S_Ball(0) ausgeführt wird.
ReDim StructAbfrage(MeshID)
;Hier könntest du genau so gut einfach "If StructAbfrage(MeshID) = #False" hinschreiben
If Defined(P_Struct, #PB_Procedure) <> StructAbfrage(MeshID)
StructAbfrage(MeshID) = #True
Global Dim S_Box.S_Box(0)
Debug "#######"
Debug index
Debug "#######"
Debug " "
EndIf
;Wenn du die Procedure einmal mit index = 2 und dann mit index = 1 aufrufst, dann
;wird S_Box(2) nicht mehr existieren, weil das Array dann wieder verkleinert wird.
ReDim S_Box.S_Box(index)
S_Box.S_Box(index)\TestBox = 88*index
EndProcedure
;Hier der selbe Kram wie oben.
Procedure P_Create_MyBall(index)
Protected MeshID = 2
ReDim StructAbfrage(MeshID)
If Defined(P_Struct, #PB_Procedure) <> StructAbfrage(MeshID)
StructAbfrage(MeshID) = #True
Global Dim S_Ball.S_Ball(0)
Debug "#######"
Debug index
Debug "#######"
EndIf
ReDim S_Ball.S_Ball(index)
S_Ball.S_Ball(index)\TestBall = 7*index
EndProcedure
P_Create_MyBox(1)
P_Create_MyBox(2)
P_Create_MyBox(3)
P_Create_MyBall(1)
P_Create_MyBall(2)
P_Create_MyBall(3)
;--------------------------------------------------
Define i
For i = 1 To 3
Debug "-------------"
Debug S_Box.S_Box(i)\TestBox
Debug S_Ball.S_Ball(i)\TestBall
NextCode: Alles auswählen
EnableExplicit
Structure S_Box
TestBox.i
EndStructure
Structure S_Ball
TestBall.i
EndStructure
Global Dim S_Box.S_Box(0)
Global Dim S_Ball.S_Ball(0)
Procedure P_Create_MyBox(index)
If (ArraySize(S_Box()) < index)
ReDim S_Box.S_Box(index)
EndIf
S_Box.S_Box(index)\TestBox = 88 * index
EndProcedure
Procedure P_Create_MyBall(index)
If (ArraySize(S_Ball()) < index)
ReDim S_Ball.S_Ball(index)
EndIf
S_Ball.S_Ball(index)\TestBall = 7 * index
EndProcedure
P_Create_MyBox(1)
P_Create_MyBox(2)
P_Create_MyBox(3)
P_Create_MyBall(1)
P_Create_MyBall(2)
P_Create_MyBall(3)
;--------------------------------------------------
Define i
For i = 1 To 3
Debug "-------------"
Debug S_Box.S_Box(i)\TestBox
Debug S_Ball.S_Ball(i)\TestBall
Next