Lack in pb manual about Procedures explanation
Posted: Fri Apr 17, 2009 10:06 am
There is not said that this can not be done:Syntax
Procedure[.<type>] name(<parameter1[.<type>]> [, <parameter2[.<type>] [= DefaultValue]>, ...])
...
[ProcedureReturn value]
EndProcedure
Description
A Procedure is a part of code independent from the main code which can have any parameters and it's own variables. In PureBasic, a recurrence is fully supported for the procedures and any procedure can call it itself. At each call of the procedure the variables inside will start with a value of 0 (null). To access main code variables, they have to be shared them by using Shared or Global keywords (see also the Protected and Static keywords).
The last parameters can have a default value (need to be a constant expression), so if these parameters are omitted when the procedure is called, the default value will be used.
Like variables also arrays and linked lists can be passed as parameters to the procedure using the Array or List keyword.
A procedure can return a value or a string if necessary. You have to set the type after Procedure and use the ProcedureReturn keyword at any moment inside the procedure. A call of ProcedureReturn exits immediately the procedure, even when its called inside a loop.
ProcedureReturn can't be used to return an array or a linked list. For this purpose pass the array or the linked list as parameter to the procedure.
If no value is specified for ProcedureReturn, the returned value will be undefined (see inline assembly for more information).
Note: To return strings from DLLs, see DLLs. For advanced programmers ProcedureC is available and will declare the procedure using 'CDecl' instead of 'StandardCall' calling convension.
Selected procedures can be executed asynchronously to the main program by using of threads.
Code: Select all
Structure ier
a.f
EndStructure
Procedure Th(his.ier)
EndProcedure
In other words, in the manual seems not said that input parameters for procedures must be all only in any of the internal native types, pointers, or Array or List.