Forum
LRIM/RTRIM/TRIM built in functions - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Wishlist (https://www.boriel.com/forum/forumdisplay.php?fid=14)
+---- Thread: LRIM/RTRIM/TRIM built in functions (/showthread.php?tid=1153)



LRIM/RTRIM/TRIM built in functions - RandomiserUsr - 08-01-2021

It would be handy to have a 

LTRIM
RTRIM
TRIM

functions built in to ZXB

I know you could right one but I wonder if there is a faster way to be compiled?

thanks


RE: LRIM/RTRIM/TRIM built in functions - boriel - 08-03-2021

(08-01-2021, 10:00 AM)RandomiserUsr Wrote: It would be handy to have a 

LTRIM
RTRIM
TRIM

functions built in to ZXB

I know you could right one but I wonder if there is a faster way to be compiled?

thanks

Cool Good idea. I will include them in the next release.
Indeed there is a duplicated str library, and one of them will be removed.
I'll keep you updated with this.


RE: LRIM/RTRIM/TRIM built in functions - boriel - 08-07-2021

(08-01-2021, 10:00 AM)RandomiserUsr Wrote: It would be handy to have a 

LTRIM
RTRIM
TRIM

functions built in to ZXB

I know you could right one but I wonder if there is a faster way to be compiled?

thanks

Ok, I've implemented ltrim(s, subs), rtrim(s, subs) and trim(s, sub) which trim the string subs in the respective side of s.
They're in #include <string.bas> in this new version:

http://www.boriel.com/files/zxb/zxbasic-1.15.1-beta1.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.1-beta1.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.1-beta1-win32.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.1-beta1-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.1-beta1-macos.tar.gz

Please, try it and tell me Cool 

An example:
Code:
#include <string.bas>

print "'"; ltrim("", "a"); "'"
print "'"; ltrim("hello world", ""); "'"
print "'"; ltrim("hello world", "he"); "'"
print "'"; ltrim("hehello world", "he"); "'"
print "'"; ltrim("hehehe", "he"); "'"



RE: LRIM/RTRIM/TRIM built in functions - RandomiserUsr - 08-13-2021

Thanks for doing this :-) nice one