Hello everybody.

Here are 3 functions I often use instead of LTrim(), RTrim() and Trim(), that I find

restrictives.

LTrimstring(), RTrimstring() and Trimstring()

In fact these functions do the same thing than LTrim(), RTrim() and Trim(), but I added

an optional argument which allow to change the default searched string 'Space' by the one

you indicate.

These 3 functions could replace LTrim(), RTrim() and Trim(), and because the second

argument is optional, previous scripts using these functions will still work as attended.

function LTrimString($a, optional $b)
$LTrimString=''
if vartype($b)=0 $b=' ' endif
if $a and $b and vartype($a)=8 and vartype($b)=8
while left($a,len($b))=$b
$a=substr($a,len($b)+1)
loop
$LTrimString=$a
endif
endfunction

function RTrimString($a, optional $b)
$RTrimString=''
if vartype($b)=0 $b=' ' endif
if $a and $b and vartype($a)=8 and vartype($b)=8
while right($a,len($b))=$b
$a=substr($a,1,len($a)-len($b))
loop
$RTrimString=$a
endif
endfunction

function TrimString($a, optional $b)
; Dependencies : Ltrimstring(), Rtrimstring
$TrimString=''
if vartype($b)=0 $b=' ' endif
if $a and $b and vartype($a)=8 and vartype($b)=8
$a=LTrimString($a,$b)
$a=RTrimString($a,$b)
$TrimString=$a
endif
endfunction

Try LTrimstring('\winnt','\')
and Trimstring(@ldrive,'\')
or Rtrimstring(@scriptname,'.kix')

Let me know if this helps or what you think about.

I wish you all a good day.
_________________________
Comments always welcome. French native so I apologize for my (mis)use of English!