Old 18th January 2005, 20:48   #1
JedBartlett
Junior Member
 
Join Date: Jan 2005
Posts: 4
a message box after MUI_PAGE_DIRECTORY?

Hi,

I have an install script that lets the user choose his install dir using this page:

!insertmacro MUI_PAGE_DIRECTORY

What I need to do is not allow them to select a directory that contains spaces (ex. "c:\program files\abc" is not allowed).

How can I add a function that looks for spaces in the INSTDIR and, if there are spaces, shows a message box and returns back to the MUI_PAGE_DIRECTORY page?

Any help is greatly appreciated!

Jed
JedBartlett is offline   Reply With Quote
Old 18th January 2005, 21:05   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You can set up a Leave function like so:

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "checkInstDir"
!insertmacro MUI_PAGE_DIRECTORY

This is what you need:
http://nsis.sourceforge.net/archive/...ances=0,11,122

-Stu
Afrow UK is offline   Reply With Quote
Old 18th January 2005, 21:13   #3
Jnuw
Senior Member
 
Join Date: Sep 2004
Location: Wisconsin, US
Posts: 258
JedBartlett,

Add this line right above your !insertmacro MUI_PAGE_DIRECTORY line:

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"

Then add a function like this:

Function DirectoryLeave
<check $INSTDIR for spaces here, goto end if no spaces>
MessageBox MB_OK "$INSTDIR contains spaces, try again"
Abort
End:
FunctionEnd


This will allow the user to hit the next or install button, but will then run the DirectoryLeave function, and if your $INSTDIR contains spaces, will show the messagebox and loop them back to the MUI_PAGE_DIRECTORY page to allow them to fix their error.

As for the <check $INSTDIR for spaces here, goto end if no spaces>, I’m not sure how to check for spaces in a string ($INSTDIR), but someone will come along shortly and tell you that part. This should get you started, I’ll keep checking on that line.
Jnuw is offline   Reply With Quote
Old 18th January 2005, 21:15   #4
Jnuw
Senior Member
 
Join Date: Sep 2004
Location: Wisconsin, US
Posts: 258
How about this:

C.4 Search in a string
; StrStr
; input, top of stack = string to search for
; top of stack-1 = string to search in
; output, top of stack (replaces with the portion of the string remaining)
; modifies no other variables.
;
; Usage:
; Push "this is a long ass string"
; Push "ass"
; Call StrStr
; Pop $R0
; ($R0 at this point is "ass string")

Function StrStr
Exch $R1 ; st=haystack,old$R1, $R1=needle
Exch ; st=old$R1,haystack
Exch $R2 ; st=old$R1,old$R2, $R2=haystack
Push $R3
Push $R4
Push $R5
StrLen $R3 $R1
StrCpy $R4 0
; $R1=needle
; $R2=haystack
; $R3=len(needle)
; $R4=cnt
; $R5=tmp
loop:
StrCpy $R5 $R2 $R3 $R4
StrCmp $R5 $R1 done
StrCmp $R5 "" done
IntOp $R4 $R4 + 1
Goto loop
done:
StrCpy $R1 $R2 "" $R4
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch $R1
FunctionEnd
Jnuw is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump