### Inline Java Global Vars usage

In case Inline Java is required, which require global vars, then these can be used as outlined below.
An example of using Inline Java is controlling (get/set data) TinkerForge Bricklets.
B4J Code
`Sub Process_Globals
Private fx As JFX
Private MainForm As Form
'Declare the addfunction class
Private af As addfunction
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main")
MainForm.Show
'
af.Initialize
MainForm.close
End Sub`
BAS Code addfunction Class
`Sub Class_Globals
'These vars are used, in lowercase, by the Inline Java code. Add ignore to avoid the var not used message
Private Result, N1, N2 As Int 'ignore
Private joInline As JavaObject = Me
End Sub`
`Public Sub Initialize
'Assign values to the global vars
N1 = 10
N2 = 20
'Run the inline java code function. The global var result contains the result of the addition.
joInline.RunMethod("Add", Null)
'Show the result
Log("Result: " & Result)
End Sub`
If JAVA
//Test function add. the global vars must contain an underscore and in lowcase.
//See also the generated b4j source code in the src folder.
public void Add() {
_result = _n1 + _n2;
}
End If

Changed: , Category: Inline Java, File: T6C201M1476.htm, ID: 1476