Announcement

Collapse
No announcement yet.

ledDigitsDisplay for unsigned long numbers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ledDigitsDisplay for unsigned long numbers

    Hi,
    I had also to display a u32 number. So here the code for ledDigitsDisplay for unsigned long numbers.

    Code:
    func ledDigitsDisplay32(var newval, var index, var left, var Digits, var MinDigits, var WidthDigit, var LeadingBlanks)
        var i, k, l, p, num[10], tnum[10];
        var ff[4], fh[4];
        to(fh); print([DEC] Digits);
        to(ff); print("%");
        str_Cat(str_Ptr(ff), str_Ptr(fh));
        str_Cat(str_Ptr(ff), "lu\0");
        l := str_Ptr(newval);
        to(num); str_Printf(&l, ff);
        l := str_Ptr(num);
        for (i := 0; i < Digits; i++)
            k := str_GetByte(l++) & 0x0f;
            if (LeadingBlanks && (i < Digits - MinDigits))
                if (k == 0)
                    k := 10;
                else
                    LeadingBlanks := 0 ;
                endif
            endif
            img_SetWord(hndl, index, IMAGE_INDEX, k);
            img_SetWord(hndl, index, IMAGE_XPOS, left+i*WidthDigit) ;
            img_Show(hndl, index);
        next
    endfunc
    Enjoy

    Best Regards,
    Manfred

  • #2
    Hello Manfred,

    Thank you again for sharing your code.
    This will be helpful on the 4D community!

    Best Regards,
    Kevin

    Comment

    Working...
    X