Trim quotes

From NSIS Wiki

Author: Afrow UK (talk, contrib)


Description

Trims single leading and trailing double quotes (").

The Function

Function TrimQuotes
Exch $R0
Push $R1
 
  StrCpy $R1 $R0 1
  StrCmp $R1 `"` 0 +2
    StrCpy $R0 $R0 `` 1
  StrCpy $R1 $R0 1 -1
  StrCmp $R1 `"` 0 +2
    StrCpy $R0 $R0 -1
 
Pop $R1
Exch $R0
FunctionEnd
 
!macro _TrimQuotes Input Output
  Push `${Input}`
  Call TrimQuotes
  Pop ${Output}
!macroend
!define TrimQuotes `!insertmacro _TrimQuotes`

Usage

StrCpy $0 `"blah"`
${TrimQuotes} $0 $0
DetailPrint $0
Personal tools
donate