最新消息:

TextReplace是NSIS文本文档字符串查找替换的插件

nsis 永恒心锁 2292浏览 0评论
/*
TextReplace是NSIS文本文档字符串查找替换的插件
TextReplace可以从文本文档中查找到相应的字符串如"abc"并且返回一共找到的个数,可以将替换后的内容保存到新的文本文档里,也可以在原文件中进行替换.
*/
!AddIncludeDir "../Include"
!AddPluginDir "../Plugins"
Name "TextReplaceTest"
OutFile "TextReplaceTest.exe"
!include "TextReplace.nsh"
!include "Sections.nsh"
Var RADIOBUTTON
Page components
Page instfiles
Section "Basic" Basic
${textreplace::FindInFile} "$EXEDIRinput.txt" "abc" "/S=1" $0
MessageBox MB_OK '已经在文档中找到$0个字符串"abc"$n$rtextreplace::FindInFile$n$$0={$0}'
${textreplace::ReplaceInFile} "$EXEDIRinput.txt" "$EXEDIRoutput.txt" "abc" "xyz" "/S=1 /C=1 /AO=1" $0
MessageBox MB_OK 'textreplace::ReplaceInFile$n$$0={$0}'
${textreplace::Unload}
SectionEnd
Section /o "FindIt as pointer" FindItPointer
${textreplace::FillReadBuffer} "$EXEDIRinput.txt" $0
MessageBox MB_OK 'textreplace::FillReadBuffer$n$$0={$0}'
${textreplace::FindInFile} "$EXEDIRinput.txt" "$0" "/PI=1" $1
MessageBox MB_OK 'textreplace::FindInFile$n$$1={$1}'
${textreplace::FreeReadBuffer} "$0"
${textreplace::Unload}
SectionEnd
Section /o "ReplaceWith as pointer" ReplaceWithPointer
${textreplace::FillReadBuffer} "$EXEDIRReplaceWith.txt" $0
MessageBox MB_OK 'textreplace::FillReadBuffer$n$$0={$0}'
${textreplace::ReplaceInFile} "$EXEDIRinput.txt" "$EXEDIRoutput.txt" "abc" "$0" "/PO=1" $1
MessageBox MB_OK 'textreplace::ReplaceInFile$n$$1={$1}'
${textreplace::FreeReadBuffer} "$0"
${textreplace::Unload}
SectionEnd
Section /o "ReplaceIt and ReplaceWith as pointers" ReplaceItReplaceWithPointers
${textreplace::FillReadBuffer} "$EXEDIRReplaceIt.txt" $0
MessageBox MB_OK 'textreplace::FillReadBuffer$n$$0={$0}'
${textreplace::FillReadBuffer} "$EXEDIRReplaceWith.txt" $1
MessageBox MB_OK 'textreplace::FillReadBuffer$n$$1={$1}'
${textreplace::ReplaceInFile} "$EXEDIRinput.txt" "$EXEDIRoutput.txt" "$0" "$1" "/S=1 /C=1 /PI=1 /PO=1" $2
MessageBox MB_OK 'textreplace::ReplaceInFile$n$$2={$2}'
${textreplace::FreeReadBuffer} "$0"
${textreplace::FreeReadBuffer} "$1"
${textreplace::Unload}
SectionEnd
Function .onInit
StrCpy $RADIOBUTTON ${Basic}
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $RADIOBUTTON
!insertmacro RadioButton ${Basic}
!insertmacro RadioButton ${FindItPointer}
!insertmacro RadioButton ${ReplaceWithPointer}
!insertmacro RadioButton ${ReplaceItReplaceWithPointers}
!insertmacro EndRadioButtons
FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » TextReplace是NSIS文本文档字符串查找替换的插件

您必须 登录 才能发表评论!