StrRev: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Reverse a string) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{PageAuthor|Lloigor}} | {{PageAuthor|Lloigor}} | ||
== Description == | |||
Reverse a string. | |||
== Usage == | |||
<highlight-nsis>${StrRev} $StrVar "String" ;; $StrVar="gnirtS"</highlight-nsis> | |||
== Function == | |||
<highlight-nsis>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | <highlight-nsis>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; Reverse a string | ;; Reverse a string | ||
Line 34: | Line 41: | ||
FunctionEnd</highlight-nsis> | FunctionEnd</highlight-nsis> | ||
[[Category:String Functions]] | [[Category:String Functions]] |
Latest revision as of 03:08, 22 October 2011
Author: Lloigor (talk, contrib) |
Description
Reverse a string.
Usage
${StrRev} $StrVar "String" ;; $StrVar="gnirtS"
Function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Reverse a string ;; P1 :o: Reversed string ;; P2 :i: Original string ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; !define StrRev "!insertmacro _StrRev" !macro _StrRev _REV_ _STR_ Push "${_STR_}" Call StrRev Pop ${_REV_} !macroend Function StrRev Exch $1 ;; Orig string Push $0 ;; Reversed string Exch Push $2 ;; String Len / Counter Push $3 ;; Current character StrCpy $0 "" StrLen $2 "$1" IntCmp $2 0 +5 IntOp $2 $2 - 1 StrCpy $3 "$1" 1 $2 StrCpy $0 "$0$3" Goto -4 Pop $3 Pop $2 Pop $1 Exch $0 FunctionEnd