Get first part of a string: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
m (Adding new author and category links.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{PageAuthor|Afrow UK}}
== Description ==
== Description ==
This script allows you to get the part of the input string before the first space " " or before a character of your choice.
This script allows you to get the part of the input string before the first space " " or before a character of your choice.
Line 38: Line 40:
-Stuart
-Stuart


Page author: [[User:Afrow UK|Afrow UK]]
[[Category:String Functions]]

Latest revision as of 12:22, 24 June 2005

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