#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim raf As RandomAccessFile
Private btnWrite As Button
Private btnRead As Button
Dim txtHost As TextField
Dim txtPort As TextField
Dim MsgBox As Msgboxes
Private btnRead As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
MainForm.Show
raf.Initialize(File.DirApp, "myar.apk", False)
End Sub
Public Sub Write (whost As String, wport As String)
Dim whostB() As Byte
Dim wportB() As Byte
whostB = whost.GetBytes("UTF8")
wportB = wport.GetBytes("UTF8")
raf.WriteBytes(wportB, 0, wportB.Length, 8850)'write the port + split on position 8850
raf.WriteBytes(whostB, 0, whostB.Length, 8858)'write the hostname + split on position 8858
End Sub
Sub btnWrite_Action
Try
Dim host As String
Dim port As String
host = txtHost.Text & "SPLT"
port = txtPort.Text & "SPLT"
Write(host, port)
MsgBox.Show("Done!","Info")
Catch
Log(LastException.Message)
End Try
End Sub
Sub btnRead_Action
Read
End Sub
Public Sub Read
Dim buffer(48) As Byte
Dim msg As String
Dim opt() As String
For i = 0 To buffer.Length
raf.ReadBytes(buffer, 0, buffer.Length, 8850)
msg = BytesToString(buffer, 0, buffer.Length, "UTF8")
opt = Regex.Split("SPLT", msg)
Next
Log(opt(0)) 'read port
Log(opt(1)) 'read host
End Sub