PDA

View Full Version : [QOD] len-fixed strings



ReneMiner
21-02-2013, 13:26
Dim theString as String * 1


So Question is: What will theString contain now?

Petr Schreiber
21-02-2013, 18:37
Oh no,

I was so sure it will be $SPC ... but it is $NUL! :oops:

Let's undo my mistake by giving some sample code on how to determine ascii value of given string character:


Uses "Console"

Function TBMain()

Dim theString As String * 1
Byte asciiValue1

asciiValue1 = Asc(theString)
PrintL "ASC(s):", asciiValue1

asciiValue1 = Asc(theString, 1)
PrintL "ASC(s,1):", asciiValue1

Byte asciiValue2 At StrPtr(theString)
PrintL "Virtual variable:", asciiValue2

asciiValue1 = Peek(Byte, StrPtr(theString))
PrintL "Peek:", asciiValue1

Byte asciiValue3( Len(theString) ) At StrPtr(theString)
PrintL "Virtual array:", asciiValue3(1)

PrintL
PrintL "Press any key to continue..."
WaitKey

End Function



Petr