Hello World

Blank project

1. Create a Console (Non-UI) project using B4J

'Non-UI application (console / server application)
'#Region Project Attributes 
'	#CommandLineArgs:
'	#MergeLibraries: True 
'#End Region

Sub Process_Globals
	
End Sub

Sub AppStart (Args() As String)
	Log("Hello world!!!")
End Sub

2. Adding BANano library

Sub Process_Globals
	Private App As BANano
End Sub

Sub AppStart (Args() As String)
	' Initialize banano object with event, appname (must not have space) and version
	App.Initialize("BANano", "www", 1)
	
	' The name of the html file
	App.HTML_NAME = "index.html"
	
	' The title of the page
	App.Header.Title = "My BANano App"
	
	' Transpile B4J code to html, css and javascript and store output in File.DirApp
	' The website will be loaded in \Objects\App where you saved your project
	App.Build(File.DirApp)
	'ExitApplication
End Sub

Sub BANano_Ready
	Dim body As BANanoElement = App.GetElement("#body")
	body.Append("Hello Aeric!")
End Sub

3. Run the project

UI project

1. Create a UI project using B4J. An UI project allows us to open the browser to view the page automatically.

2. Using BANano and JFX libraries

'#Region Project Attributes 
'	#MainFormWidth: 600
'	#MainFormHeight: 600 
'#End Region

Sub Process_Globals
	Private App As BANano
	Private fx As JFX
End Sub

Sub AppStart (Form1 As Form, Args() As String)
	' Initialize banano object with event, appname (must not have space) and version
	App.Initialize("BANano", "www", 1)
	
	' The name of the html file
	App.HTML_NAME = "index.html"
	
	' The title of the page
	App.Header.Title = "My BANano App"

	' Transpile B4J code to html, css and javascript and store output in File.DirApp
	App.Build(File.DirApp)
	
	' The website will be loaded in \Objects\App where you saved your project
	Dim URL As String = File.GetUri(File.Combine(File.DirApp, "www"), "index.html")
	fx.ShowExternalDocument(URL)
	
	ExitApplication
End Sub

Sub BANano_Ready
	Dim body As BANanoElement = App.GetElement("#body")
	body.Append("Hello Aeric!")
End Sub

3. Adding Bootstrap CSS

4. Load the CSS file

	App.Header.Title = "My BANano App"

	' Add a Bootstrap CSS
	App.Header.AddCSSFile("bootstrap.min.css")

	App.Build(File.DirApp)

5. Run the project. The font is now different.

Leave a comment

Your email address will not be published. Required fields are marked *