; Trim ; Removes leading & trailing whitespace from a string ; Usage: ; Push ; Call Trim ; Pop Function Trim Exch $R1 ; Original string Push $R2 Loop: StrCpy $R2 "$R1" 1 StrCmp "$R2" " " TrimLeft StrCmp "$R2" "$\r" TrimLeft StrCmp "$R2" "$\n" TrimLeft StrCmp "$R2" "$\t" TrimLeft GoTo Loop2 TrimLeft: StrCpy $R1 "$R1" "" 1 Goto Loop Loop2: StrCpy $R2 "$R1" 1 -1 StrCmp "$R2" " " TrimRight StrCmp "$R2" "$\r" TrimRight StrCmp "$R2" "$\n" TrimRight StrCmp "$R2" "$\t" TrimRight GoTo Done TrimRight: StrCpy $R1 "$R1" -1 Goto Loop2 Done: Pop $R2 Exch $R1 FunctionEnd !define Trim "!insertmacro Trim" !macro Trim ResultVar String Push "${String}" Call Trim Pop "${ResultVar}" !macroend Function CheckForSpaces Exch $R0 Push $R1 Push $R2 Push $R3 StrCpy $R1 -1 StrCpy $R3 $R0 StrCpy $R0 0 loop: StrCpy $R2 $R3 1 $R1 IntOp $R1 $R1 - 1 StrCmp $R2 "" done StrCmp $R2 " " 0 loop IntOp $R0 $R0 + 1 Goto loop done: Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd