Get first part and rest of string: 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 53: | Line 53: | ||
-Stu | -Stu | ||
Page author: Afrow UK | Page author: [[User:Afrow UK|Afrow UK]] |
Revision as of 12:38, 23 April 2005
Description
This is another simple string which outputs the 1st part of a string (before a specified character) and outputs the rest of the string (after the specified character)
Usage
Push "|" ;divider char Push "string1|string2|string3|string4|string5" ;input string Call SplitFirstStrPart Pop $R0 ;1st part ["string1"] Pop $R1 ;rest ["string2|string3|string4|string5"]
The Function
Function SplitFirstStrPart Exch $R0 Exch Exch $R1 Push $R2 Push $R3 StrCpy $R3 $R1 StrLen $R1 $R0 IntOp $R1 $R1 + 1 loop: IntOp $R1 $R1 - 1 StrCpy $R2 $R0 1 -$R1 StrCmp $R1 0 exit0 StrCmp $R2 $R3 exit1 loop exit0: StrCpy $R1 "" Goto exit2 exit1: IntOp $R1 $R1 - 1 StrCmp $R1 0 0 +3 StrCpy $R2 "" Goto +2 StrCpy $R2 $R0 "" -$R1 IntOp $R1 $R1 + 1 StrCpy $R0 $R0 -$R1 StrCpy $R1 $R2 exit2: Pop $R3 Pop $R2 Exch $R1 ;rest Exch Exch $R0 ;first FunctionEnd
I used this script to get values from a multiline text box (by firstly replacing all " " with "|").
-Stu
Page author: Afrow UK