Is it possible to check a string for a given character (example ^C) as this tells my software to do something
I am at the moment using
Code: Select all
if Loz = "^C" then
Code: Select all
b05018374320766^C
This is my code I am using to get serial data from the scanner if anyone out there can see where i have gone wrong I would most appreciate being told so i know for the future
Code: Select all
' Gambas class file
Public RS232Scanner As SerialPort
Public TTimer As Timer
Public ScannerData As String
Public Sub Form_Open()
If Args.Count > 1 Then
Select Case Lower(Args[1])
Case "/setup", "/Setup"
Case "/hiden", "Hiden"
FMain.FullScreen = False
FMain.Visible = False
Case ""
FMain.Center
FMain.Resizable = False
End Select
End If
RS232Scanner = New SerialPort As "RS232Scanner"
TTimer = New Timer As "TTimer"
TTimer.Delay = 500
Global.SystemBootUp
'Set up the Serial Device so it should start talking
With RS232Scanner
.PortName = Global.Scanner_SerialPortName
.Speed = Global.Scanner_SerialBandRate
Select Case Global.Scanner_SerialDataParity
Case "none", "None"
.Parity = SerialPort.None
Case "odd", "Odd"
.Parity = SerialPort.Odd
Case "even", "Even"
.Parity = SerialPort.Even
End Select
Select Case Global.Scanner_SerialDataBits
Case "5"
.DataBits = SerialPort.Bits5
Case "6"
.DataBits = SerialPort.Bits6
Case "7"
.DataBits = SerialPort.bits7
Case "8"
.DataBits = SerialPort.bits8
End Select
Select Case Global.Scanner_SerialStopBits
Case "1"
.StopBits = SerialPort.bits1
Case "2"
.StopBits = SerialPort.Bits2
End Select
Select Case Global.Scanner_SerialFlowControl
Case "none", "None"
.FlowControl = SerialPort.None
Case "hardware", "Hardware"
.FlowControl = SerialPort.hardware
Case "software", "Software"
.FlowControl = SerialPort.Software
Case "both", "Both"
.FlowControl = SerialPort.both
End Select
End With
Try RS232Scanner.Open(3)
If Error Then
Global.AddToListBox("Sorry Unable to connect to Scanner\nPlease check settings and try again")
Else
If RS232Scanner.Status = Net.Active Then
TTimer.Start()
Global.AddToListBox(" DTR :" & RS232Scanner.DTR)
Global.AddToListBox(" DSR :" & RS232Scanner.DSR)
Global.AddToListBox("Blocking :" & RS232Scanner.Blocking)
Global.AddToListBox(" CTS :" & RS232Scanner.CTS)
Global.AddToListBox(" RTS :" & RS232Scanner.RTS)
End If
End If
End
Private Sub Form_Close()
If RS232Scanner.Status = Net.Active Then
RS232Scanner.Close
FMain.Close
End If
End
Public Sub RS232Scanner_Read()
Dim i As Integer = 0
Dim Loz As String = Read #RS232Scanner, Lof(RS232Scanner)
Print Loz
If Loz = "^C" Then
ScannerData = ""
Else
ScannerData &= Loz
Endif
End
Public Sub TTimer_Timer()
Dim TempStore As String = ScannerData
ScannerData = Mid$(TempStore, 4, Len(TempStore))
If FMain.ListBox1.Count = 13 Then FMain.ListBox1.Clear
If RS232Scanner.Status = Net.Active Then
If ScannerData <> "" Then
Global.AddToListBox("Barcode Number from Scanner :" & ScannerData)
ScannerData = ""
End If
Endif
End