On Apr 5, 9:10 pm, [email protected] wrote:
> Revision: 1874
> Author: jsuijs
> Date: Mon Apr  5 13:09:27 2010
> Log: fix of print_string to handle 0-terminated strings, shorter than the  
> array size.http://code.google.com/p/jallib/source/detail?r=1874
>
> Modified:
>   /trunk/include/jal/print.jal
>
> =======================================
> --- /trunk/include/jal/print.jal        Fri Mar 26 14:18:01 2010
> +++ /trunk/include/jal/print.jal        Mon Apr  5 13:09:27 2010
> @@ -47,7 +47,8 @@
>      var word len = count(str)
>      var byte i
>
> -   for len using i loop
> +   for len using i loop
> +      if (str[i] == 0) then exit loop end if
>         device = str[i]
>      end loop

That will break some code!

I have one GLCD text driver that if the character is 0 to 15, it
prints the Hex digit in 3x5 font.
also if it's a terminal command, a non-terminal can be 0.

I recommend 255 as Null on microcontrollers / PIC as it's not
typically used as ASCII and returned reading uninitialised eeprom.

Assuming you want a Null terminated string.
Just because C uses 0 (original Mini-Computers) doesn't make it a good
idea for PIC and JAL.

I also use 255 for no keypress.

-- 
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.

Reply via email to