Check for spaces in a directory path: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
m (Updated author links.)
Line 1: Line 1:
{|align=right
|<small>Author: [[{{ns:2}}:Afrow UK|Afrow UK]] ([[{{ns:3}}:Afrow UK|talk]], [[{{ns:-1}}:Contributions/Afrow UK|contrib]])</small>
|}
<br style="clear:both;">
== Description ==
== Description ==
This script will tell the user that he has entered spaces (" ") in the installation directory.
This script will tell the user that he has entered spaces (" ") in the installation directory.
Line 45: Line 49:
</highlight-nsis>
</highlight-nsis>
-Stu
-Stu
Page author: [[User:Afrow UK|Afrow UK]]

Revision as of 23:14, 29 April 2005

Author: Afrow UK (talk, contrib)


Description

This script will tell the user that he has entered spaces (" ") in the installation directory. This can be used if you don't want spaces in the directory path, and should be placed in the directory page's leave function (because if the directory page has spaces, then it will go back to the directory page).

Updated 10th October 2003

Usage

Non-MUI

Page Directory "" "" "CheckForSpaces"

MUI

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "CheckForSpaces"
!insertmacro MUI_PAGE_DIRECTORY

== The Function ==

Function CheckForSpaces
 Push $R1
 Push $R2
 Push $R3
 Push $R4
 StrCpy $R1 -1
 StrCpy $R3 0
 loop:
   StrCpy $R2 $INSTDIR 1 $R1
   IntOp $R1 $R1 - 1
   StrCmp $R2 "" done
   StrCmp $R2 " " found
   StrCpy $R4 "$R2$R4"
 Goto loop
 found:
   IntOp $R3 $R3 + 1
 Goto loop
 done:
   StrCmp $R3 0 +3
   MessageBox MB_OK|MB_ICONEXCLAMATION "Error: The Installaton directory \
 has $R3 spaces.$\nPlease remove the spaces."
   Abort
 Pop $R4
 Pop $R3
 Pop $R2
 Pop $R1
FunctionEnd

-Stu