<< Prev        Next >>

ID : 5279

CallByName

Function

To call a Procedure and execute it. Unlike Call command, you can use a formula for procedure name.

Syntax

CallByName procedure name[, argument list[,return value]]

Guaranteed Entry

Procedure name 
Designate a procedure name to be called by String Type data.
Argument list
Designate an argument given to the procedure by Variant Type array.
Return value

Designate a variable to put return value into according to the type of return value of called procedure. This is available only when there is a return value at Function procedure, other cases will be ignored.

Description

At the time of program execution, evaluate a formula designated as a procedure name and create the procedure name dynamically to Call. This is useful to Call sequential named programs at a time.

Related Terms

Call, others are the same as Call.

Attention

Refer to Call.
Unlike Call command, CallByName cannot pass an argument by reference. If an argument to be invoked is specified by ByRef (pass-by-reference), it will treat that ByVal (pass-by-value) is specified.
For the ByRef (pass-by-reference), and ByVal (pass-by-value), refer to the "Calling a Procedure with Argument" of PROGRAMMER'S MANUAL.

Example

In the following example, use Function procedure Hoge1 to Hoge5 to create names of For sentence dynamically and Call them. There are three arguments between Hoge1 and Hoge5, so the element defines 3 arrays in CallByName.

'!TITLE "Call and Execute of Procedure Using a Formula"
'Pro1.pcs
Sub Main 
	TakeArm Keep = 0
	Dim lRes As Integer
	Dim n As Integer
	
	'Create procedure name Hoge1 to Hoge5 using a formula and call them
	For n = 1 To 5
		'Designate an argument given to the procedure by an array
		CallByName "Hoge" & n, Array( "Hoge" & n, n, P[n] ), lRes
		PrintDbg lRes
	Next
End Sub

Function Hoge1( ByVal sVal As String, ByVal lCnt As Integer, 
ByVal posCur As Position ) As Integer
	Hoge1 = lCnt
End Function

Function Hoge2( ByVal sVal As String, ByVal lCnt As Integer, 
ByVal posCur As Position ) As Integer
	Hoge2 = lCnt
End Function

Function Hoge3( ByVal sVal As String, ByVal lCnt As Integer, 
ByVal posCur As Position ) As Integer
	Hoge3 = lCnt
End Function

Function Hoge4( ByVal sVal As String, ByVal lCnt As Integer, 
ByVal posCur As Position ) As Integer
	Hoge4 = lCnt
End Function

Function Hoge5( ByVal sVal As String, ByVal lCnt As Integer, 
ByVal posCur As Position ) As Integer
	Hoge5 = lCnt
End Function

ID : 5279

<< Prev        Next >>