Chapter 5: Communication Protocol
Appendix B: Continued….. (Sample Translation routine in Visual BASIC)
Function LookUpOSDString(sTextMessage As String) As String
‘
‘ Look up chars and translate to message for OSD
‘
Dim iLoop As Integer
Dim sNewMess As String
Dim sChar As String
sNewMess = Space$(MAX_SCREEN_CHAR)
For iLoop = 1 To Len(sTextMessage)
sChar = Mid$(sTextMessage, iLoop, 1)
Select Case sChar
Case “0” To “9”
Mid$(sNewMess, iLoop, 1) = Chr$(Asc(sChar) - 48)
Case “A” To “Z”
Mid$(sNewMess, iLoop, 1) = Chr$(Asc(sChar) - 53)
Case “a” To “z”
Mid$(sNewMess, iLoop, 1) = Chr$(Asc(sChar) - 55)
Case “.”
Mid$(sNewMess, iLoop, 1) = Chr$(&H27)
Case “ “
Mid$(sNewMess, iLoop, 1) = Chr$(&HB)
Case “:”
Mid$(sNewMess, iLoop, 1) = Chr$(&H26)
Case “/”
Mid$(sNewMess, iLoop, 1) = Chr$(&H28)
Case “‘“
Mid$(sNewMess, iLoop, 1) = Chr$(&H29)
Case “-”
Mid$(sNewMess, iLoop, 1) = Chr$(&HA)
Case “?”
Mid$(sNewMess, iLoop, 1) = Chr$(&H70)
Case “*”
Mid$(sNewMess, iLoop, 1) = Chr$(&H5F)
Case “=”
Mid$(sNewMess, iLoop, 1) = Chr$(&H78)
Case “>”
Mid$(sNewMess, iLoop, 1) = Chr$(&H7A)
Case “<“
Mid$(sNewMess, iLoop, 1) = Chr$(&H7B)
Case “(“
Mid$(sNewMess, iLoop, 1) = Chr$(&H61)
Case “)”
Mid$(sNewMess, iLoop, 1) = Chr$(&H62)
Case Else
Mid$(sNewMess, iLoop, 1) = Chr$(&HB)
End Select
Next iLoop
LookUpOSDString = sNewMess
End Function