function
Purpose
Create a user defined function
Description
Allows the user to create their own functions. This allows code to be reused and makes it easier to read and maintain
Syntax
function name() ... return value // function with no arguments
function name(argument1, ... argumentn) ... return value // function with n arguments
Arguments
name name of the function
argument1 first parameter of the function
argumentn last parameter of the function
value return value of the function (void if no value is returned)
Example
for size = 1 to 200 step 1 loop
clear()
centreText( "Hello World", size )
update()
repeat
// Centre a text string on the screen
function centreText( message, size )
textSize( size )
tw = textWidth( message )
drawText( ( gWidth() - tw ) / 2, ( gHeight() - size ) / 2, size, white, message )
return void
Associated Commands