Sort String 1 (from end): Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
m (Updated author and download links, and changed format of some pages.)
Line 47: Line 47:
-Stu
-Stu


Page author: Afrow UK
Page author: [[User:Afrow UK|Afrow UK]]

Revision as of 12:36, 23 April 2005

Description

This script will output all after x spaces, where x is the space count from the end of the input string.

Usage

Push "I am Afrow UK"
Push 2
 Call SimpStrSort
Pop $R0

$R0 will now be "Afrow UK", since "Afrow UK" is after the 2nd space from the end of the string.

The Function

Function SimpStrSort
  Exch $4 ; count to get part
  Exch
  Exch $0 ; input string
  Push $1
  Push $2
  Push $3
  StrCpy $1 0
  StrCpy $3 1
  loop:
    IntOp $1 $1 - 1
    StrCpy $2 $0 1 $1
    StrCmp $2 "" exit2
    StrCmp $2 " " next ; replace " " with whatever you like
    Goto loop
  next:
    StrCmp $3 $4 exit
    IntOp $3 $3 + 1
  Goto loop
  exit2:
    IntOp $1 $1 - 1
  exit:
    IntOp $1 $1 + 1
    StrCpy $0 $0 "" $1
    Pop $3
    Pop $2
    Pop $1
    Exch $0 ; output string
FunctionEnd

-Stu

Page author: Afrow UK