Randy - 2014-01-07

I was trying to make a character set for my LCD as it doesn't have character functions built in.
I needed to get the ascii value of a single character but couldn't find a built in function to do that. Well looking through the GLCD code I found this

~~~~~~~~~~~~~~
Sub GLCDPrint(In PrintLocX, In PrintLocY, PrintData As String)
PrintLen = PrintData(0)
If PrintLen = 0 Then Exit Sub
GLCDPrintLoc = PrintLocX

'Write Data
For SysPrintTemp = 1 To PrintLen
    GLCDDrawChar GLCDPrintLoc, PrintLocY, PrintData(SysPrintTemp)
    GLCDPrintLoc += 6
Next

End Sub

'''Draws a character at the specified location
'''@hide
Sub GLCDDrawChar(In CharLocX, In CharLocY, In CharCode)
~~~~~~~~~~~~~

PrintData is a string going into GLCDPrint but is sent as PrintData(SysPrintTemp) (one element of the string). But GLCDDrawChar takes it as an integer thus changing it from a string to an ascii value.

Neat trick! I'm not sure if it is soft error checking or automatic conversion by the complier but it works!

 
Last edit: Randy 2014-01-07