如何使用charStrip nsis

问题描述 投票:0回答:1

我不太确定我是否理解如何使用charStrip,所以我创建了下面的脚本并且没有在$ current_compare上显示任何内容,请帮助 我试着调用这个函数但是没有用。

Exch $R0 #char <br/>
Exch <br/>
Exch $R1 #in string <br/>
Push $R2 <br/>
Push $R3 <br/>
Push $R4 <br/>
 StrCpy $R2 -1 <br/>
 IntOp $R2 $R2 + 1 <br/>
 StrCpy $R3 $R1 1 $R2 <br/>
 StrCmp $R3 "" +8 <br/>
 StrCmp $R3 $R0 0 -3 <br/>
  StrCpy $R3 $R1 $R2 <br/>
  IntOp $R2 $R2 + 1 <br/>
  StrCpy $R4 $R1 "" $R2 <br/>
  StrCpy $R1 $R3$R4 <br/>
  IntOp $R2 $R2 - 2 <br/>
  Goto -9 <br/>
  StrCpy $R0 $R1 <br/>
Pop $R4 <br/>
Pop $R3 <br/>
Pop $R2 <br/>
Pop $R1 <br/>
Exch $R0 <br/>
FunctionEnd <br/>

OutFile test.exe <br/>

Var /GLOBAL CURRENT_COMPARE <br/>
Section 1 <br/>
  !macro CharStrip Char InStr OutVar <br/>
  Push '.' <br/>
  Push 'v8.11.3' <br/>
  Call CharStrip <br/>
 Pop '$CURRENT_COMPARE' <br/>
!macroend <br/>
MessageBox MB_OK $CURRENT_COMPARE <br/>
 SectionEnd <br/>
installer nsis
1个回答
0
投票

我假设你从Wiki修改了this code

在您的示例中,您没有插入宏,因此永远不会调用CharStrip函数。您不应该修改宏,只需传递正确的参数:

Function CharStrip
Exch $R0 #char
Exch
Exch $R1 #in string
Push $R2
Push $R3
Push $R4
 StrCpy $R2 -1
 IntOp $R2 $R2 + 1
 StrCpy $R3 $R1 1 $R2
 StrCmp $R3 "" +8
 StrCmp $R3 $R0 0 -3
  StrCpy $R3 $R1 $R2
  IntOp $R2 $R2 + 1
  StrCpy $R4 $R1 "" $R2
  StrCpy $R1 $R3$R4
  IntOp $R2 $R2 - 2
  Goto -9
  StrCpy $R0 $R1
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
!macro CharStrip Char InStr OutVar
 Push '${InStr}'
 Push '${Char}'
  Call CharStrip
 Pop '${OutVar}'
!macroend
!define CharStrip '!insertmacro CharStrip'

Var /GLOBAL CURRENT_COMPARE

Section 1
${CharStrip} '.' 'v8.11.3' $CURRENT_COMPARE
MessageBox mb_OK $CURRENT_COMPARE
SectionEnd
© www.soinside.com 2019 - 2024. All rights reserved.