Get first part of a string
From NSIS Wiki
Jump to navigationJump to search
Author: Afrow UK (talk, contrib) |
Description
This script allows you to get the part of the input string before the first space " " or before a character of your choice.
Usage
Push "HelloAll I am Afrow UK, and I love NSIS" ; Input string Call GetFirstStrPart Pop "$R0"
Where $R0 will now be "HelloAll"
The Function
Function GetFirstStrPart Exch $R0 Push $R1 Push $R2 StrLen $R1 $R0 IntOp $R1 $R1 + 1 loop: IntOp $R1 $R1 - 1 StrCpy $R2 $R0 1 -$R1 StrCmp $R2 "" exit2 StrCmp $R2 " " exit1 ; Change " " to "\" if ur inputting dir path str Goto loop exit1: StrCpy $R0 $R0 -$R1 exit2: Pop $R2 Pop $R1 Exch $R0 FunctionEnd
Written by me (Afrow UK)
-Stuart