Call

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Script structure > Functions/Subs >

Call

 

Description

 

Executes a function or dynamically execute a function name or a command name if dynamically passed by a string expression.

 

Syntax

 

Call FunctionName[(Arguments)] [TO Variable]

 

Returns

 

Parameters

 

Name

Type

Optional

Meaning

Variable


Yes

Any variable to which it is possible to assign a value

 

Remarks

 

FunctionName is the name of the function to be executed.

 

If FunctionName starts with a quoted string or with a string variable, CALL will try to valuate FunctionName as a string expression.

A script function with the name of the string expression will be searched and if present, executed.

If no script function will be found, a language command will be searched and if present, executed.

 

If FunctionName evaluates to a number, CALL will consider it as a function pointer and will try to valuate call it directly.

 

Restrictions

 

See also

 

Examples

 

'--------------------------------------------------------------------------

'---EXAMPLE 1: script function

'--------------------------------------------------------------------------

Dim s      As String = "m15,3ds,txt"

Dim n      As Long

Dim Result As Long

 

n = 1

'---CALL will call function whose name is 'My3DSLOADER'  

Call "My" + PARSE$(s,",",2)+"LOADER" ( n, s) To Result

MSGBOX 0, n & $CRLF & Result

 

Function My3DSLoader( ByRef x As LongByVal t As String ) As Long

  MSGBOX 0, t & "<< there should be a string"

  x = x * 2

  Function = X * 10

End Function

'--------------------------------------------------------------------------

 

 

'--------------------------------------------------------------------------

'---EXAMPLE 2: language command

'--------------------------------------------------------------------------

Dim MyCmd As String

Dim MyStr As String

Dim MyNum As EXT

 

MyCmd = "mid$"

Call MyCmd ("abcdefgh", 3, 2) To Mystr

MSGBOX 0, Mystr

 

MyCmd = "sin"

Call MyCmd (0.5) To MyNum

MSGBOX 0, MyNum

'--------------------------------------------------------------------------