Hi Joep,
Even better would be to use a "ref" keyword, something discussed on jallist some weeks ago. "byte in" and "byte out" are highly confusing for me. At least "byte out", which behavior is very weird the first time you use it. When in doubt, I use "volatile byte in out"... Cheers, Seb -- Sébastien Lelong http://www.sirloon.net http://sirbot.org 2009/8/16 Joep Suijs <[email protected]> > Hi Guys, > > Just ran into some unexpected behaviour. I wrote: > > chr = 0 > serial_hw_read(chr) > if (chr == 0) then return end if > > And it did not work like it should. This is how it should be: > > if (serial_hw_read(chr) == false) then return end if > > However.... the code in _serial_hw_read() is > > if PIR1_RCIF then > data = RCREG > PIR1_RCIF = false -- [email protected] 12-sept-08 > else > return false ;result = false > end if > > When false is returned, there 'data' is not touched. Why doesn't is work > then. Well, because: > function _serial_hw_read(byte *out* data) return bit is > > The value 0 assigned is not passed to the function, so it is not returned. > So all works like it should, but is it like we want it to be? I was fooled > here and so might others. Maybe it would be a good idea to never use 'out' > without 'in'? What do you think? > > Joep > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
