CALL

Syntax: CALL subname ([parameter list])
Type: statement

Calls a sub like in this code snipet:

call foobar (35, 42)

This is old syntax compadibile from the oldest basic dialects. This can be better coded like so:

foobar 35, 42

See also declare, calls, sub.

Differences:
Between QB:
Function must have been declared already.

CALLOCATE

same as ALLOCATE, but clears the contents.

Differences:
New to FreeBasic.

calls

Type: statement

Redundant, and the same as call. Kept for compadibility reasons.

Differences:
Between QB:
Function must have be declared already.

CASE

Type: keyword
Category: control flow

See select case.

CBYTE

Type: function

Converts any numeric expression to a byte.
CUBYTE, CUSHORT and CUINT, same as CBYTE, CSHORT and CINT, but work with unsigned types (v1c)

e.g. this will try convert 260 into 8-bits.


dim x as integer
print cbyte(260)

Differences:
New to FreeBasic.

CDBL

Type: function

Converts any numeric expression to a double-precision number.

cDbl can be explained like so: C-DBL, C (convert) Dbl (double).

CDECL

Syntax: declare {function | sub} procName cdecl alias
Type: calling convention

Stands for C-Declare, which when used with a declare statement passes the variables from right to left (cc++ convention), rather than left to right (fb convention).

e.g. declaring 'pixelColor' from the SDL library.


declare function pixelColor cdecl alias "pixelColor" (byval dst as SDL_Surface ptr, byval x as Sint16, byval y as Sint16, byval color as Uint32) as integer

----------------
I've no clue how VB will "mangle" the imported names, try adding ALIAS "AddNumbers@8" to the VB prototype, or declare it as CDECL at the FB side and as ALIAS "_AddNumbers" at VB.

---------------
See also declare, pascal, stdcall.

Differences:
New to FreeBasic.

CHAIN

Type: statement

Runs another program and transfers control to that program. After called program has ended the original program will gain the control again.

See also run.

Differences:
Between QB:
Calling process will continue running after called process finish, rather than not (like in qb).

CHDIR

Syntax: chdir pathspec
Type: statement
Category: File

Changes the current directory.

If in windows or dos, this changes the current directory on the given drive but does not change the default drive. You must change (v1c, not finished)

CHR$

Syntax: CHR$(byte)
Type: function

Returns the ascii character of the byte given, returned in a single-character string format.
CHR$ now accepts multiple arguments as in "s = chr$( 65, 66, 67, 68 )" (v1c)


This is useful for accessing symbol's not on the keyboard.

CINT

Type: function

Converts any number to an integer by removing the fractional part.
CUBYTE, CUSHORT and CUINT, same as CBYTE, CSHORT and CINT, but work with unsigned types (v1c)

See also int.

CIRCLE

Syntax: CIRCLE [STEP] (x,y), radius[, [color][, [start][, [end][, [aspect][, F]]]]]
Type: statement
Category: Gfx

Statement to draw circles, ellipses or arcs.

The 'STEP' option specify that x and y are offsets relative to the current graphics cursor position.

'x' and 'y' are coordinates of the center of the circle/ellipse.

'radius' is simply the radius of the circle (or major axis radius of an ellise).

'color' is the color attribute. This is mode specific, see COLOR and SCREEN (graphics) for details.

'start' and 'end' are angles are in radians. These can range -2PI to 2PI; if you specify a negative angle, its value is changed sign and a line is drawn from the center up to that point in the arc. End angle can be less than start angle. If you do not specify start and end, a full circle/ellipse is drawn; if you you specify start but not end, end is assumed to be 2PI; if you specify end but not start, start is assumed to be 0.

'aspect' is the aspect ratio, or the ratio of the y radius over the x radius. The default value is the value required to draw a perfect circle on the screen, keeping pixel aspect ratio in mind.

So this value can be calculated as follows:

ratio = (y_radius / x_radius) * pixel_aspect_ratio



Where pixel_aspect_ratio is the ratio of the current mode width over the current mode height, assuming a 4:3 standard monitor. If aspect ratio is less than 1, radius is the x radius; if aspect is more or equal to 1, radius is the y radius.

'f' is the fill flag. If you specify this flag, the circle/ellipse will be filled with the selected color. This has no effect if you're drawing an arc.

Use this function to draw circles, ellipses or arcs. Custom coordinates system set up by WINDOW and/or VIEW (graphics) affect the drawing operation; clipping set by VIEW also applies. When CIRCLE finishes drawing, the current graphics cursor position is set to the supplied center.

e.g.


' Set 640x480 mode and draws a circle in the center
SCREEN 18
CIRCLE (320, 240), 200, 15
' Draws a filled ellipse
CIRCLE (320, 240), 200, 2, , , 0.2, F
' Draws a small arc
CIRCLE (320, 240), 200, 4, 0.83, 1.67, 3



See also screen (graphics), color.

Differences:
Between QB:
As this function uses a different algorithm from the one used in QB, circles, ellipses and arcs may not be equal pixel-by-pixel to those produced by QB. In addition, this version supports filled circles/ellipses via the F flag, whereas QB doesn't.

CLEAR

Syntax: clear pointer, value, bytecount
Type: statement

Resets all values in an array to what you want (usually 0 is useful).

e.g.

dim array(1 to 100) as integer
clear byref Array(1), 0, len(Array(1)) * ubound(Array)



See also dim.

CLNG

Type: function

Converts any number to a long number. The name can be explained by c-lng (c for convert, lng for long).

CLOSE

Type: statement

Closes one file (in a given file slot #) or closes all files (with no parameter given).

CLS

Syntax: CLS
Type: statement
Category: Console

Clears the console screen.

Differences:
Between QB:
There's no optional argument, the whole screen is cleared.

color

Syntax: COLOR [foreground][,background]
Type: statement
Category: Gfx

Sets the display foreground / background color that is used with console output and graphics output of text.

The COLOR statement sets the current foreground and/or background colors. CIRCLE, DRAW, LINE (graphics), CLS, PAINT, PRINT and PSET all use the last colors set by this function when you don't specify a color to them, where applicable. The color values COLOR accepts depend on the current gfx mode.

Mode 1:
	foreground is screen color (ranging 0-15).
	background modulo 4 is the emulated CGA palette to be used:
		0:	green, red, and brown.
		1:	cyan, magenta and white.
		2:	same as 0, but with bright colors.
		3:	same as 1, but with bright colors.
Modes 2 and 11:
	foreground is a color index in current palette (ranging 0-1).
	background is a color index in current palette (ranging 0-1).
Modes 7 and 8:
	foreground is a color index in current palette (ranging 0-15).
	background is screen color index in current palette (ranging 0-15).
Mode 9:
	foreground is a color index in current palette (ranging 0-63).
	background is screen color index in current palette (ranging 0-63).
Mode 12:
	foreground is a color index in current palette (ranging 0-15).
	background is a color index in current palette (ranging 0-15).
Modes 13 and up:
	foreground is a color index in current palette (ranging 0-255).
	background is a color index in current palette (ranging 0-255).



If you are using a color depth higher than 8bpp, foreground and background are direct RGB color values in the form &hRRGGBB, where RR, GG and BB are the red, green and blue components ranging &h00-&hFF (0-255 in decimal notation). While in hi/truecolor modes, you can also use the RGB function to obtain a valid color value.

e.g.


' Sets 800x600 in 32bpp color depth
SCREEN 19, 32
' Sets orange foreground and dark blue background color
COLOR &hFF8000, &h000040
' Say hello
CLS
LOCATE 19, 44: PRINT "Hello World!"
SLEEP



See also screen (graphics), palette.

Differences:
Betweeen QB:
Foreground range: 0..15, background range: 0..7; there's no border argument.
FB version accepts direct color values in hi/truecolor modes; COLOR in screen mode 1 accepts 4 different CGA palettes instead of the 2 supported by QB.

COMMAND$

Type: function

Returns command line parameters used to call the program.
COMMAND$ can now return just a specific argument as in "argv3 = command$(3)" (v1c)   

COMMON

Type: statement

Shares variables between modules.

No example as of now.

See also dim, sub, function.

Differences:
Between QB:
Arrays are ALWAYS dynamic; no sharing between processes.
 

CONS:

 special file names, to open the console for i/o access and the std error for output (v1c)
ERR:

 

CONST

Type: statement

Creates symbols which act as a constant (a integer/decimal number or string).
string constant expressions can now be used with CONST's (v1c)

e.g. to make the symbol 'red' to 4 and 'blue' to 1 you would do:

const red = 4, blue = 1



Or to create a string constant:

const msg = "Hello world!"

continue

Syntax: continue {do | for | while}
Type: statement

Re-enters a code block such as a do...loop, for...next, or a while...wend block.

e.g. the second and third print command will not be seen. (Warning, infinite loop - press ctrl+break to exit!)


do
print "i will always be shown"
continue do
print "i will never be shown"
loop
print "neither will I"



See also exit.

Differences:
New to FreeBasic.

COS

Syntax: COS (angle as single)
Type: function
Category: math

Returns the cosine of the angle (given in radians).

CSHORT

Converts any numeric expression to a short integer (16-bit).
CUBYTE, CUSHORT and CUINT, same as CBYTE, CSHORT and CINT, but work with unsigned types (v1c)

No example.

Differences:
New to FreeBasic.

CSIGN

Syntax: csign (unsigned number)
Type: function

Converts an unsigned number to a signed number, in the same sized data type.

Only useful to force signed behaviour of division or multiplication (including with shl and shr).


dim a as ushort
a = 65000
print csign(a) 10



This is the opposite of cunsg.

Differences:
New to FreeBasic.

CSNG

Type: function

Converts any number to a single-precision number.

CSRLIN

Type: function
Category: Console

Returns the current line position (row) of the cursor.

The name can be explained by csr-lin (csr for cursor, lin for line).

CUNSG

Syntax: cunsg (signed number)
Type: function

Converts a signed number to an unsigned number, in the same sized data type.

Only useful to force unsigned behaviour of division or multiplication (including with shl and shr).

e.g.


dim a as short
a = -200
print cunsg(a) 10



This is the opposite of csign.

Differences:
New to FreeBasic.

curdir$

Syntax: curdir$
Type: function
Category: file

Returns the current directory/folder.

e.g.


print curdir$



See also open, dir$, mkdir, rmdir.

Differences:
New to FreeBasic.

CVD

Syntax: CVD(8-byte-string)
Type: function

Converts an 8-byte-string created with MKD$ back to a double-precision number.

CVI

Syntax: CVI(2-byte-string)
Type: function

Converts a 2-byte-string created with MKI$ back to an integer.

CVL

Syntax: CVL(4-byte-string)
Type: function

Converts a 4-byte-string created with MKL$ back to a
long integer.

CVS

Syntax: CVS(4-byte-string)
Type: function

Converts a 4-byte-string created with MKS$ back to a single-precision number.