Recent changes

2013-04-14 2013-04-02 2013-02-17 2013-01-29 2013-01-20 2013-01-18 2012-12-08 2012-11-06 2012-09-04 2012-08-02

NSIS/Scripts



Scripts

GetInQuotes: Get string from between quotes

""で囲まれた文字列を抽出する関数 GetInQuotes: Get string from between quotes

WordReplace

WordReplace - NSIS

IndexOf

IndexOf & RIndexOf: Find index of character in string 対象の文字が文字列の先頭から何番目にあるかを返す関数。

${IndexOf} $R0 "blah" "a"

とした場合、$R0には2が入る。

<code> ; @author Afrow UK http://nsis.sourceforge.net/Special:Contributions/Afrow_UK Function IndexOf Exch $R0 Exch Exch $R1 Push $R2 Push $R3


StrCpy $R3 $R0
StrCpy $R0 -1
IntOp $R0 $R0 + 1
 StrCpy $R2 $R3 1 $R0
 StrCmp $R2 "" +2
 StrCmp $R2 $R1 +2 -3

StrCpy $R0 -1

Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd

!macro IndexOf Var Str Char Push "${Char}" Push "${Str}"

Call IndexOf

Pop "${Var}" !macroend !define IndexOf "!insertmacro IndexOf" </code>

RIndexOf

IndexOf & RIndexOf: Find index of character in string

対象の文字が文字列の後ろから何番目にあるかを返す関数。

${RIndexOf} $R0 "blah" "b"

としたとき、$R0は4が入る。

<code> Function RIndexOf Exch $R0 Exch Exch $R1 Push $R2 Push $R3


StrCpy $R3 $R0
StrCpy $R0 0
IntOp $R0 $R0 + 1
 StrCpy $R2 $R3 1 -$R0
 StrCmp $R2 "" +2
 StrCmp $R2 $R1 +2 -3

StrCpy $R0 -1

Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd

!macro RIndexOf Var Str Char Push "${Char}" Push "${Str}"

Call RIndexOf

Pop "${Var}" !macroend !define RIndexOf "!insertmacro RIndexOf" </code>

LineFind

LineFind ファイルの中の特定の行に対して指定の関数を適用する。

${LineFind} "[File1]" "[File2|/NUL]" "[LineNumbers]" "Function"
File1:読み込むファイル。

GetBetween: Get text in between two markers in a file

GetBetween: Get text in between two markers in a file 指定文字列の間にある文字列を返す関数マクロ。

"This message is invalid"

という文字列が保存されたIn_This.txtがあったとして

${GetBetween} "This" "is" "$INSTDIRIn_This.txt" "$R0"

とした場合$R0には" message "が格納される。

Comment