'
Are my TRIM functions an improvement over the existing DOS TIPS functions ?
They accept exact trim or trim by occurence:
Code: Select all
%_forX% ( '$FullPathFile, "\"' ) %@TrimLeft%
%_forX% ( '$FullPathFile, 3' ) %@TrimLeft%
%_forX% ( '$FullPathFile, "\"' ) %@TrimRight%
%_forX% ( '$FullPathFile, 3' ) %@TrimRight%
code snippet of @TrimLeft:
Code: Select all
set ^"%$Defines%=!@Udelim! ( %$n1c%
!_forTS! ( "%$Defines%" ) !@SetLocal! %$n1c%
!_forL! ( '"#Var,""%%~a""", "$Val,""%%~a"",#", "#strORint,""%%~b"""' ) !@Param! %$n1c%
!_necho! ^^^!$Trace^^^!: '%%~a' %$n1c%
if defined $Val if %%~b NEQ +%%~b ( %$n1c%
set "$Val=^!$Val:*%%~b=^!" %$n1c%
) else set "$Val=^!$Val:~0,-%%~b^!" %$n1c%
set "%%~a=^!$Val^!" %$n1c%
!_necho! %%~a: '^^^!$Val^^^!' %$n1c%
!_forL! ( '^^^!$Return^^^!, %%~a' ) !@EndLocal! ^&!@nError! %$n1c%
)"
code snippet of @TrimRight:
Code: Select all
set ^"%$Defines%=!@Udelim! ( %$n1c%
!_forTS! ( "%$Defines%" ) !@SetLocal! %$n1c%
!_forL! ( '"#Var,""%%~a""", "$Val,""%%~a"",#", "#strORint,""%%~b"""' ) !@Param! %$n1c%
!_necho! ^^^!$Trace^^^!: '%%~a' %$n1c%
if defined $Val if %%~b NEQ +%%~b ( %$n1c%
set "$Last=^!$Val:%%~b=" "^!" %$n1c%
set $Last="^!$Last^!" %$n1c%
!_forTS! ( ^^^!$Last^^^! ) do set "$Last=%%~^!" %$n1c%
set "$Last=%%~b^!$Last^!###" %$n1c%
set "$Val=^!$Val^!###" %$n1c%
for %%? in ( %$n1c%
"^!$Last^!" %$n1c%
) do set "$Val=^!$Val:%%~?=^!" %$n1c%
) else set "$Val=^!$Val:~0,-%%~b^!" %$n1c%
set "%%~a=^!$Val^!" %$n1c%
!_necho! %%~a: '^^^!$Val^^^!' %$n1c%
!_forL! ( '^^^!$Return^^^!, %%~a' ) !@EndLocal! ^&!@nError! %$n1c%
)"
CPU3G; loadtime: '+-50ms', exectime; '+-50ms', executions: '+-20p/sec'