4D SYSTEMS FORUM

Register New Posts
 
 
 


Reply
 
Author Comment
 
samit_ray

Registered: 11/05/12
Posts: 52
Reply with quote  #1 

str_GetW() is a great call .
A lot of the string processing on my ardunio moved to GFX.

However there is a strange bug/Behaviour
If str_GetW() encounters a 0 in the string it does not convert it and status returned is 0 (fail)

for e.g   E06|00|16

works great till the first pipe (|) and returns 6 as expected , then for the next two chars it fails (returns 0) and value in the &var remains unchnaged
then after the second | it work correctly and returns 16

I assumed that if it encounters 0 it will conver all 0's to 0 move the pointer to the second pipe and return success ( 1)
or is the current behaviour the "provided" behaviour

Regards

meldavia

Registered: 18/03/07
Posts: 900
Reply with quote  #2 
Hi,

str_GetW is working as intended, here is an example that checks it.

var c, p, n;
    var string[10];
    to(string); putstr("E06|00|16");

    p := str_Ptr(string);
    repeat
        if (str_GetW(&p, &n))
            print("number ", n, "\n");
        else if (str_GetC(&p, &c))
            print("character ", [CHR] c,  "\n");
        else
            break;
        endif
    forever

    repeat forever


result is:-
character E
number 6
character |
number 0
character |
number 16

__________________
Regards,
Dave
samit_ray

Registered: 11/05/12
Posts: 52
Reply with quote  #3 
got to try this one out, i must be blind if this is working correctly.
Have a few other issues that require more attention (see other thread)

Thanks for the nifty peice of code below
samit_ray

Registered: 11/05/12
Posts: 52
Reply with quote  #4 
My sample was incorrect,

change it to
putstr("E06|0|16");

character E
number 6
character |
character 0   (it should have detected as number)
character |
number 16
meldavia

Registered: 18/03/07
Posts: 900
Reply with quote  #5 
Hi, yes unfortunately you are correct, will not work for a single zero followed by a character that is > 0x21 (space).

The only temporary workaround is to follow any single zero's with a space.

It will be fixed in the next PmmC release

__________________
Regards,
Dave
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Powered by Website Toolbox - Create a Website Forum Hosting, Guestbook Hosting, or Website Chat Room for your website.