Where to put keyboard code

General FreeBASIC programming questions.
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Where to put keyboard code

Post by badidea »

Gablea wrote:... html basic attenuation ...
What is that? DDG and Google weren't much help here.
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where to put keyboard code

Post by Gablea »

badidea wrote:
Gablea wrote:... html basic attenuation ...
What is that? DDG and Google weren't much help here.
I may have spelt it wrong

this is a sample of the code I use to get the terminals status

Code: Select all

        Try
            Dim Request As HttpWebRequest = HttpWebRequest.Create(PS_URL & "/terminals/" & TerminalIDNumber)
            Dim credentials As String = Convert.ToBase64String(Encoding.ASCII.GetBytes(PS_USER & ":" & PS_PASS))
            txtResults.Text = vbNullString

            With Request
                .Proxy = Nothing
                .Headers(HttpRequestHeader.Authorization) = String.Format("Basic {0}", credentials)
                .UserAgent = PS_USER
            End With

            Dim response As HttpWebResponse = Request.GetResponse()
            Dim dataStream As Stream = response.GetResponseStream
            Dim reader As New StreamReader(dataStream)
            Dim responseFromServer As String = reader.ReadToEnd()

            txtResults.Text = responseFromServer


            If responseFromServer = "0" Then
                MsgBox("Retreal of Status Failed")
            Else
                Dim json As String = responseFromServer
                Dim ser As JObject = JObject.Parse(json)
                Dim data As List(Of JToken) = ser.Children().ToList
                For Each item As JProperty In data
                    item.CreateReader()
                    Select Case item.Name
                        Case "status"
                            Select Case item.Value
                                Case "AVAILABLE"
                                    SendToPoSterminal("TerminalOnLine|")
                                    addtoStatusList("Terminal Ready")

                                Case "BUSY"
                                    SendToPoSterminal("TerminalBusy|")
                                    addtoStatusList("Terminal busy please wait 10 seconds and try again")

                                Case "Offline", "OFFLINE", "offline"
                                    SendToPoSterminal("offline|")
                                    addtoStatusList("Terminal OFFLINE NO Card processing Possible")
                            End Select
                    End Select
                Next
            End If
        Catch ex As Exception
            addtoStatusList(ex.ToString)
            SendToPoSterminal("ProcessingError")
        End Try

so the PS_URL, TerminalIDNumber, PS_USER and PS_PASS are loaded from a ini file at start up of the program
Post Reply