沒有陣列支持無插件所以我離開了陣列部分。
任何字符串操作可以在NSIS(strlen的,STRCPY和的strcmp)的3個基本字符串函數來執行:
!include LogicLib.nsh
Function SplitArg
Exch $0 ; str
Push $1 ; inQ
Push $3 ; idx
Push $4 ; tmp
StrCpy $1 0
StrCpy $3 0
loop:
StrCpy $4 $0 1 $3
${If} $4 == '"'
${If} $1 <> 0
StrCpy $0 $0 "" 1
IntOp $3 $3 - 1
${EndIf}
IntOp $1 $1 !
${EndIf}
${If} $4 == '' ; The end?
StrCpy $1 0
StrCpy $4 ' '
${EndIf}
${If} $4 == ' '
${AndIf} $1 = 0
StrCpy $4 $0 $3
StrCpy $1 $4 "" -1
${IfThen} $1 == '"' ${|} StrCpy $4 $4 -1 ${|}
killspace:
IntOp $3 $3 + 1
StrCpy $0 $0 "" $3
StrCpy $1 $0 1
StrCpy $3 0
StrCmp $1 ' ' killspace
Push $0 ; Remaining
Exch 4
Pop $0
StrCmp $4 "" 0 moreleft
Pop $4
Pop $3
Pop $1
Return
moreleft:
Exch $4
Exch 2
Pop $1
Pop $3
Return
${EndIf}
IntOp $3 $3 + 1
Goto loop
FunctionEnd
Section
push 'Location "Welcome to india" Bangalore Channai "IT city" Mysore'
loop:
call SplitArg
Pop $0
StrCmp $0 "" done
DetailPrint Item=|$0|
goto loop
done:
SectionEnd
是它工作,謝謝。但是,我如何使它像$ {StrTok}一樣工作? – Roy
如果您想要$ {StrTok},爲什麼不使用它?我更改了代碼以逐個返回字符串... – Anders
因爲我不知道如何處理引號$ {StrTok} – Roy