Sort String 3 modified: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.) |
m (Adding new author and category links.) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Afrow UK}} | |||
== Description == | == Description == | ||
This is the same as the [[Sort String 3]] script, but instead works from the start instead of the end of the input string. | This is the same as the [[Sort String 3]] script, but instead works from the start instead of the end of the input string. | ||
Line 70: | Line 68: | ||
-Stu (Afrow UK) | -Stu (Afrow UK) | ||
[[Category:String Functions]] |
Latest revision as of 13:52, 24 June 2005
Author: Afrow UK (talk, contrib) |
Description
This is the same as the Sort String 3 script, but instead works from the start instead of the end of the input string.
Usage
Push "jajaja hello\muahah jajaj\lalala " ;input string Push "\" ;centre character Push " " ;right character Push " " ;left character Call StrSortLR2 Pop $0
$0 = hello\muahah (not jajaj\lalala" in StrSortLR case)
The Function
Function StrSortLR2 Exch $0 ;left character Exch Exch $1 ;right character Exch Exch 2 Exch $2 ;centre character Exch 2 Exch 3 Exch $3 ;input string Exch 3 Push $4 Push $5 StrLen $5 $3 loop1: IntOp $5 $5 - 1 StrCpy $4 $3 1 -$5 StrCmp $4 "" error StrCmp $4 $2 0 loop1 IntOp $5 $5 - 1 loop2: StrCpy $4 $3 1 -$5 IntOp $5 $5 - 1 StrCmp $4 "" loop3 StrCmp $4 $1 0 loop2 IntOp $5 $5 + 1 StrCpy $3 $3 -$5 StrLen $5 $3 loop3: IntOp $5 $5 - 1 StrCpy $4 $3 1 -$5 StrCmp $4 "" error StrCmp $4 $0 0 loop3 IntOp $5 $5 - 1 StrCpy $3 $3 "" -$5 Goto exit error: StrCpy $3 error exit: StrCpy $0 $3 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 ;output string FunctionEnd
-Stu (Afrow UK)