peterae 0 Posted December 27, 2006 Report Share Posted December 27, 2006 (edited) Hi Firstly i love this boostbasic,I cant wait for the full release. Ok my problem is that i want to use the Chr Function, I am reading a byte from the serial port as follows Dim Dat as byte Dim Buffer as String if pir1.RCIF = 1 then ' if a character is received then Dat = rcreg Buffer = Buffer + Chr(Dat) 'append rs232 character to Buffer .... I cant see any reference to any functions like this, is there a way i can transform Dat which is a Byte to a String Character. Also sub main() Dim ErrorPos as Integer Dim DeadBand as Integer Dim Sum as Integer ' this works Sum = ErrorPos + DeadBand If Sum < 0 then Goto notnearpos End if goto indeadband ' this doesnt If ( ErrorPos + DeadBand ) < 0 then goto notnearpos End if notnearpos: indeadband: end sub *********************** also this doesnt fail gracefully Dim Buffer(10) as byte sub main() call BufAdd() end sub sub BufAdd() Buffer = "" Buffer(0) = 0 End sub I know theres a deliberate mistake but boost basic gives an access violation. Keep up the good work Peter Edited December 27, 2006 by peterae Quote Link to post Share on other sites
Dave 0 Posted December 28, 2006 Report Share Posted December 28, 2006 peterae, Here is a solution: function Chr( c as char ) as string( 2 ) asm movf _c, W asm movwf _Chr asm movlw 0 asm movwf _Chr+1 end function Sub main() Dim c As char dim buffer(20) as string dim dat(2) as string buffer = "hello" c = 65 buffer = buffer + call Chr( c ) 'append rs232 character to Buffer Do while 1 Loop end sub Regards Dave Quote Link to post Share on other sites
peterae 0 Posted December 28, 2006 Author Report Share Posted December 28, 2006 hi Dave Thanks Peter Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.