Call

FreeBASIC

Call
 
Statement to invoke a subroutine

Syntax

Call procname ([parameter list])

Description

Calls a Sub or Function.

This keyword is a holdover from earlier dialects of BASIC, and is mainly deprecated.

In -lang qb, it can be used to call Subs in code before they are declared. The function will be implicitly Declare'd, with any parameters passed ByRef As Any.
Note: until the function is declared, no type-checking is done on the parameters, so it is up to the programmer to ensure they are of the correct type.

Example

'' Compile with -lang qb or -lang fblite

#lang "fblite"

Declare Sub foobar(ByVal x As Integer, ByVal y As Integer)
Call foobar(35, 42)

Sub foobar(ByVal x As Integer, ByVal y As Integer)
Print x; y
End Sub


'' Compile with -lang qb or -lang fblite

#lang "fblite"

Function f ( ) As Integer
f = 42
End Function

Call f ' execute function f, but ignore the answer


'' Compile with -lang qb

'$lang: "qb"

Call mysub(15, 16) '' call "mysub" before it has been declared, or even mentioned.

Sub mysub(ByRef a As Integer, ByRef b As Integer)
    
    Print a, b
    
End Sub


Dialect Differences

  • The use of Call is not allowed in the -lang fb dialect.
  • The -lang fblite dialect does not allow you to call functions that have not been previously declared.

Differences from QB

  • The procedure must have already been declared.
  • Call in QB will make a copy of all parameters, so changes made to the arguments inside the called Sub will not be reflected in the variables in the caller.

See also