Hi I just bought b4A four days ago and a newbie and this forum is the only way I could get help. I am having a problem compiling the codes..... the error is as follows:
B4A version 4.30
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Unknown member: isinitialized
Occurred on line: 47
If Serial1.IsInitialized = False Then Serial1.Initialize("Serial1")
Word: isinitialized
At first I thought it was the library problem but it isn't. I got the libraries enabled:
core (version 4.01)
RandomAccessFile (version 1.30)
Serial (1.20)
B4A version 4.30
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Unknown member: isinitialized
Occurred on line: 47
If Serial1.IsInitialized = False Then Serial1.Initialize("Serial1")
Word: isinitialized
At first I thought it was the library problem but it isn't. I got the libraries enabled:
core (version 4.01)
RandomAccessFile (version 1.30)
Serial (1.20)
B4X:
#Region Project Attributes
#ApplicationLabel: btControl
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Serial1 As Serial
End Sub
Sub Globals
'These global variables will be redec from this module.
'lared Each time the Activity Is created.
'These variables can only be accessede
Dim AlmC As Int
Private ImgLogo As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("frmmain")
ImgLogo.Width = Activity.Width
ImgLogo.Height = Activity.Height
ActiveCom.SalirApp=False
End Sub
Sub Activity_Resume
StopService(ActiveCom)
If ActiveCom.SalirApp Then
Activity.Finish
Else
If Serial1.IsInitialized = False Then Serial1.Initialize("Serial1")
ActiveCom.ActividadName ="main"
If Serial1.IsEnabled = False Then
Msgbox("Active Bluetooth.", "")
Activity.Finish
Else
Serial1.Listen
Serial1.Disconnect
Connect
End If
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
StopService(ActiveCom)
Serial1.Disconnect
End If
End Sub
Sub Connect
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i)) 'add the friendly name to the list
Next
Dim res As Int
res = InputList(l, "Select Device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
StartService(ActiveCom)
ToastMessageShow("Connection completed", False)
Else
'Servicio.connected = False
Msgbox(LastException.Message, "Connection Error.")
Serial1.Disconnect
ActiveCom.SalirApp=True
StopService(ActiveCom)
Activity.Finish
End If
End Sub
Sub TramaRecepcionada(Trama As String)
Dim Lin As String
Lin = AlmC
Do While Lin.Length <2
Lin="0"&Lin
Loop
If Trama="OK" Then
StartActivity(ActControl)
Else
EnvioComando.NuevoComando("@INICOM")
End If
End Sub