Get first part and rest of string: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library) |
m (Adding new author and category links.) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Afrow UK}} | |||
== Description == | == 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) | 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) | ||
Line 53: | Line 55: | ||
-Stu | -Stu | ||
[[Category:String Functions]] |
Latest revision as of 12:22, 24 June 2005
Author: Afrow UK (talk, contrib) |
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