PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

PPL beta 0.7a is now available!

You can download it at http://ppl.arwen.com This version has a lot of bug fixes and a good amount of new features.
For the ones that already downloaded 0.7a, please re-download it. I made a small correction in the garbage collection system. Sorry the inconveniences.
mervjoyce · 31 Jul 2004, 01:54 UTC — String length issue
Hi Kornalius,

I think the problem you fixed for me in 0.7 in regard to returning strings > 8 characters is not quite right yet.

An error still occurs when the returned string length is EXACTLY 8 characters - for all other lengths the returned value is OK. When the expected return length is expected to be exactly 8 chars there is some additional garbage at the end of the string.

My download of 0.7a was at 2145UTC (30/07) so should be the latest (updated) version.

Code:

func trim(s$)
local(i$);

i$ = 0;
while (((mid(s$,i$,1) == #32) OR (mid(s$,i$,1) == #09)) AND (i$ <= length(s$)-1))
i$++;
end;

if (i$ > (length(s$)-1))
return("");
else
s$ = mid(s$,i$,(length(s$)-i$));
end;

i$ = length(s$)-1;
while (((mid(s$,i$,1) == #32) OR (mid(s$,i$,1) == #09)) AND (i$ >= 0))
i$--;
end;

if (i$ < 0)
return("");
else
s$ = mid(s$,0,i$+1);
end;

return(s$);
end;

test$ = " 1234 ";
showmessage("trim(test$)=(4xchars)*"+str(trim(test$))+"*");
test$ = " 1234567 ";
showmessage("trim(test$)=(7xchars)*"+str(trim(test$))+"*");
test$ = " 12345678 ";
showmessage("trim(test$)=(8xchars)*"+str(trim(test$))+"*");
test$ = " 1234567890 ";
showmessage("trim(test$)=(10xchars)*"+str(trim(test$))+"*");

Thanks, I will test your code and fix it for 0.7b, which btw, should be out very shortly.
mervjoyce:

I fixed the issue with your program. It was a stupid string duplication error where I wasn't putting a \0 at the end of the string.