Funktiot ovat tärkeitä monimutkaisissa ohjelmissa. Niissä yhteen sanaan sisältyy teksti, joka on Function ja EndFunction-komennon välissä. Se vähentää paljon työn määrää jos vaikka aikoo tehdä päävalikon, jossa on nappuloita, jotka vaihtavat väriä tai tekee äänen, kun hiiri tulee sen päälle ja se vie vielä aliohjelmaan tai Labeliin. Jos ei käytä functioita niin joutuu jokaisen nappulan äänen ja kuvat laittaa, mutta funktioilla pitää tehdä se vain kerran. Esimerkiksi funktio Button. Sen perään pitää laittaa parametrit esim. Button (20,30,"Start",game) ja Function Button (x,y,name$,kohde) ja sen alle itse koodi.

Esimerkkiohjelma muokkaa

Repeat

	If SelectBox(200,30, "Exit") = True And MouseHit(1) Then Exit

DrawScreen
Forever

Function SelectBox(x,y, label$)

	x = (-TextWidth(label$)/2)+ScreenWidth()/2
	width = TextWidth(label$)
	height = TextHeight(label$)

	Color cbsilver	
	Box x , y, width, height, 1
	Color cbblack
	Box x , y, width, height, 0

	Color cbBlack
	CenterText x+width/2, y+height/2, ""+label$, 2
	
	mouseonbox = BoxOverlap(x, y, width, height, MouseX(), MouseY(), 1, 1)

	//kun hiiri ON päällä
	If mouseonbox = True And style=0 Then 
		Color cbWhite
		Box x, y, width, height, 1
		Color cbBlack
		CenterText x+width/2, y+height/2, ""+label$, 2
	EndIf
	
	If mouseonbox=True Then output=True Else output=False
	//output = True Or False (1 tai 0)
	Return output
	ClearMouse
	
EndFunction