Apart from a little typo (you wrote: MaxParam = CountString(Parametre$, ",") and not Parameter$) and the fact that arrays start with 0 (why allocate an empty element?), your example works perfectly fine with PB x64 but crashes with PB x86 because the ArraySize returns -1 after the first Call(ArrayParams(0))Kwai chang caine wrote:And i don't understand why...i have an error when the array is freeing
I'd call this a bug
Code: Select all
Prototype AllMessages(Param1$ = "", Param2$ = "", Param3$ = "")
Runtime Procedure MessageOneParameter(Text.s)
MessageRequester("Only one Parameter", Text)
EndProcedure
Runtime Procedure MessageTwoParameters(Text1.s, Text2.s)
MessageRequester("Two parameters", Text1 + Text2)
EndProcedure
Runtime Procedure MessageThreeParameters(Text1.s, Text2.s, Text3.s)
MessageRequester("Three parameters", Text1 + Text2 + Text3)
EndProcedure
Procedure CallProcedure(NomProcedure.s, Parameter$)
*PtrProc = GetRuntimeInteger(NomProcedure + "()")
Call.AllMessages = *PtrProc
MaxParam = CountString(Parameter$, ",")
Protected Dim ArrayParams.s(MaxParam)
For i = 0 To MaxParam
ArrayParams(i) = StringField(Parameter$, i+1, ",")
Next
Debug "Pre Call Size = " + ArraySize(ArrayParams())
Select MaxParam
Case 0
Call(ArrayParams(0))
Case 1
Call(ArrayParams(0), ArrayParams(1))
Case 2
Call(ArrayParams(0), ArrayParams(1), ArrayParams(2))
EndSelect
Debug "Post Call Size = " + ArraySize(ArrayParams())
Debug "------------------"
FreeArray(ArrayParams())
EndProcedure
CallProcedure("MessageOneParameter", "Hello it's KCC")
CallProcedure("MessageTwoParameters", "Hello it's KCC a second time, but it's more long")
CallProcedure("MessageThreeParameters", "Hello it's KCC another time, and this time, it's one time too much")