Posted by TBS forum member twofingers and repeated here with his kind permission:
http://www.thebackshed.com/forum/forum_posts.asp?TID=9738&PN=1&TPN=1These are CFunction versions of the LTrim and RTrim functions found elsewhere on this wiki. By all means consult that page for a description of how things work, but unless you are
incredibly pushed for flash space, you should use the versions below.
They differ in that they remove only spaces CHR(32) and do not treat TAB CHR(09) as whitespace. As CFunctions they are compact and very fast. Good work!
Note:
CFunctions and CSubs incompatibility. This article does not apply for the MicroMite eXtreme (MMX). For MMX compaible LTrim/RTrim code, go
here.
'
' piclovers LTrim version
'
CFunction ltrim1(STRING) STRING
00000000
27BDFFE0 AFBF001C AFB20018 AFB10014 AFB00010 90920000 1240002C 00801021
80830001 24020020 14620027 24900001 2E420002 1440000F 24020020 26100001
82030000 1462000C 24110001 24030020 26310001 323100FF 12510022 26100001
82020000 5043FFFB 26310001 10000003 02518823 24110001 02518823 323100FF
3C029D00 8C420040 0040F809 24040100 1220000E A0510000 24430001 26040001
2631FFFF 323100FF 00918821 92050000 A0650000 26100001 1611FFFC 24630001
10000003 8FBF001C 00801021 8FBF001C 8FB20018 8FB10014 8FB00010 03E00008
27BD0020 3C029D00 8C420040 0040F809 24040100 02518823 1000FFF4 A0510000
End CFunction
'
' RTrim like piclovers LTrim
'
CFunction rtrim1(STRING) STRING
00000000
27BDFFE0 AFBF001C AFB10018 AFB00014 90820000 1040002B 00808021 00821821
80640000 24030020 54830027 02001021 02022021 2483FFFF 8085FFFF 24040020
14A4000C 24110001 24050020 26310001 323100FF 0051202B 14800006 2463FFFF
80640000 5085FFFA 26310001 10000002 00518823 00518823 323100FF 3C029D00
8C420040 0040F809 24040100 1220000E A0510000 26030001 2631FFFF 323100FF
00718821 00401821 24630001 26100001 92040000 1611FFFC A0640000 10000003
8FBF001C 00801021 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020
End CFunction