Page 1 of 1

CallFunction for a local procedure [Resolved]

Posted: Sat Jan 03, 2026 1:21 pm
by Kwai chang caine
Hello at all

For calling a local procedure with CallFunctionFast(), i do that and that works

Code: Select all

Procedure Kcc(*Variable)
 Debug PeekS(*Variable) + " from the procedure"
 ProcedureReturn *Variable
EndProcedure

*Ptr = CallFunctionFast(@Kcc(), @"Hello")
Debug PeekS(*Ptr)(
But i want to use CallFunction() and that not works :|

Code: Select all

Procedure Kcc(*Variable)
 Debug PeekS(*Variable) + " from the procedure"
 ProcedureReturn *Variable
EndProcedure

*Ptr = CallFunction(0, "Kcc", @"Hello")

If *Ptr
 Debug PeekS(*Ptr)
Else
 Debug "The pointer is empty"
EndIf 
Is it possible to use CallFunction for a local procedure ?
Have a good day

Re: CallFunction for a local procedure

Posted: Sat Jan 03, 2026 2:32 pm
by mk-soft

Code: Select all

Procedure Kcc(*Variable)
 Debug PeekS(*Variable) + " from the procedure"
 ProcedureReturn *Variable
EndProcedure

*Ptr = CallFunctionFast(@Kcc(), @"Hello")

If *Ptr
 Debug PeekS(*Ptr)
Else
 Debug "The pointer is empty"
EndIf 

Re: CallFunction for a local procedure

Posted: Sat Jan 03, 2026 3:30 pm
by User_Russian
Please read the description of the function CallFunction().
Calls a function in the specified library, by using its name. The specified library must have previously been opened with the OpenLibrary() function. The function is expected to use the stdcall calling convention (the standard in most DLLs on Windows).
CallFunction() is not intended for calling local functions. It is needed for calling functions from a DLL / SO / DYLIB.

Use a prototype.

Code: Select all

Procedure.s Kcc(Variable.s)
 Variable + " from the procedure"
 ProcedureReturn Variable
EndProcedure

Prototype.s pKcc(Variable.s)
ProtoKcc.pKcc=@Kcc()
Debug ProtoKcc("Hello")

Re: CallFunction for a local procedure

Posted: Sat Jan 03, 2026 6:12 pm
by Kwai chang caine
Whaoouuh !!
Two greats MASTERS to help little KCC :shock: ...I'm going to play the lottery today :lol:

You'll probably laugh :lol:, but since the Prototype exist, i never understand how really to use it :oops:
When i read a simple example like above, it's still more or less understandable for me
But when i try to replace my several callfunctions...it's the disaster :shock:
It's the reason why i never use it :cry:

@User_Russian
I don't knowing CallFunction are only for DLL, i believed stupidly CallFunctionFast is quicker and use pointers, but i believed it's the "same" function, one who call "by the name" and the other "by pointer"
It's funny because at the begining of my numerous try, CallFunction(0, "Kcc", @"Hello") works, perhaps again a christmas miracle :shock: or perhaps i begin to be mad, after try something, and other thing, all the day :|

Thanks a lot at you two for your nices examples 8)
Have a very good end of day

Re: CallFunction for a local procedure [Resolved]

Posted: Sat Jan 03, 2026 7:35 pm
by mk-soft
Of course, it also goes over the function name as a string.

Code: Select all


Runtime Procedure Kcc(*Variable)
 Debug PeekS(*Variable) + " from the procedure"
 ProcedureReturn *Variable
EndProcedure

If GetRuntimeInteger("Kcc()")
  *Ptr = CallFunctionFast(GetRuntimeInteger("Kcc()"), @"Hello")
EndIf

If *Ptr
 Debug PeekS(*Ptr)
Else
 Debug "The pointer is empty"
EndIf 

Re: CallFunction for a local procedure [Resolved]

Posted: Sat Jan 03, 2026 7:41 pm
by Kwai chang caine
Waoouuhh !!!
I have forgotten this function Runtime() that i have try there are a long time :oops:
Since this time, i not use it ..

There are so much functions with PB, it's not always simple to memorise it mainly when i never use it :oops:
In fact...KCC is always in v3.94 Functions, the day of he came (Bad day for you all) :mrgreen:

Thanks a lot MASTER for this another method of call 8)
I think I'll be able to start a collection :shock:

Have a very good night