Example of B4X code


#Region Project Attributes 
	#MainFormWidth: 600
	#MainFormHeight: 600 
#End Region
#Region Form Preperation
'Template version 1.00
Sub Process_Globals
	Private fx As JFX
	Private MainForm As Form
	Private xui As XUI 'ignore
	Private Turtle As B4XTurtle
#if aaaa
	Private MenuBar1 As MenuBar
	Private Counter As Int
#end if
End Sub


Sub AppStart (Form1 As Form, Args() As String)
	MainForm = Form1
	MainForm.RootPane.LoadLayout("Main")
	MainForm.Show
End Sub

Sub MenuBar1_Action
	Dim Mi As MenuItem = Sender
	Select Mi.Tag
		Case "Restart"
			Turtle.Stop.ClearScreen.Home
			Turtle_Start
		Case "Exit"
			MainForm.Close
	End Select
End Sub
#End Region

Sub Turtle_Start
	Turtle.SetPenSize(5)
	Dim colors() As Int = Array As Int(xui.Color_Red, xui.Color_Green, xui.Color_Blue, xui.Color_Magenta)
	For i = 0 To colors.Length - 1 'important to start from 0!
		Turtle.SetPenColor(colors(i)).MoveForward(100).TurnLeft(90)
	Next
End Sub