Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 30th September 2005, 21:04   #1
fperez
Junior Member
 
Join Date: Sep 2005
Location: Daytona Beach, FL
Posts: 7
FindNext Does Not Work - Why?

Hello,

The "findNext" function does not seem to work. It's as if every time it gets executed the Uninstaller just stops executing.

Below is the code:
FindFirst $0 $1 $INSTDIR\server\webapps\*.xml
FindContextsLoop:
StrCmp $1 "" FindContextsLoopDone
${UnStrRep} $R0 "$1" ".xml" ""
MessageBox MB_OK "About to Delete Virtual Directory: $R0"
!insertmacro DELETE_VIRTUAL_DIRECTORY $R0
MessageBox MB_OK "Just deleted Virtual Directory: $R0"
MessageBox MB_OK "Dollar Zero = $0"
MessageBox MB_OK "Dollar One = $1"
FindNext $0 $1
IfErrors 0 FindContextsLoop
FindContextsLoopDone:
FindClose $0

Please help me.

Thanks!
fperez is offline   Reply With Quote
Old 30th September 2005, 22:01   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
You must clear the error flag before you use the instruction you wish to test for using IfErrors. The error flag might be set by anything executed before FindNext. You'll therefore test everything above it, not only FindNext itself.
code:
ClearErrors
FindNext $0 $1
IfErrors 0 FindContextsLoop


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 3rd October 2005, 13:23   #3
fperez
Junior Member
 
Join Date: Sep 2005
Location: Daytona Beach, FL
Posts: 7
Still Not Working

I tried the above in inside my UnInstaller code. Adding the "ClearErrors" instruction before executing "FindNext" still did not cause the program to work. When the UnIninstaller tries to execute "FindNext" it simply stops executing.

Below is the code:
StrCpy $0 ""
StrCpy $1 ""
StrCpy $R0 ""
FindFirst $0 $1 $INSTDIR\server\webapps\*.xml
FindContextsLoop:
StrCmp $1 "" FindContextsLoopDone
${UnStrRep} $R0 "$1" ".xml" ""
MessageBox MB_OK "About to Delete Virtual Directory: $R0"
!insertmacro DELETE_VIRTUAL_DIRECTORY $R0
MessageBox MB_OK "Just deleted Virtual Directory: $R0"
MessageBox MB_OK "Dollar Zero = $0"
MessageBox MB_OK "Dollar One = $1"
ClearErrors
MessageBox MB_OK "Just completed ClearErrors instruction."
MessageBox MB_OK "About to execute FindNext instruction."
FindNext $0 $1
MessageBox MB_OK "Just completed FindNext instruction."
IfErrors 0 FindContextsLoop
FindContextsLoopDone:
FindClose $0

Please help me.

Thanks.
fperez is offline   Reply With Quote
Old 3rd October 2005, 13:34   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
What exactly do you mean by "stops executing"? Does no message box show up after "About to execute FindNext instruction"? What does happen, if it doesn't show?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 3rd October 2005, 13:37   #5
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 665
Maybe some problem with handle, try to comment out:
code:
# ${UnStrRep} $R0 "$1" ".xml" ""
# !insertmacro DELETE_VIRTUAL_DIRECTORY $R0

Instructor is offline   Reply With Quote
Old 3rd October 2005, 13:43   #6
fperez
Junior Member
 
Join Date: Sep 2005
Location: Daytona Beach, FL
Posts: 7
>What exactly do you mean by "stops executing"? Does no >message box show up after "About to execute FindNext >instruction"? What does happen, if it doesn't show?

That's exactly what I mean. The next message box that should appear is the one stating "Just completed FindNext instruction." Then, the UnInstaller simply stops executing.

Any answers why?
fperez is offline   Reply With Quote
Old 3rd October 2005, 13:48   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
I believe Instructor is right. DELETE_VIRTUAL_DIRECTORY must have changed $0 and/or $1.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 3rd October 2005, 14:03   #8
fperez
Junior Member
 
Join Date: Sep 2005
Location: Daytona Beach, FL
Posts: 7
Hi. I fixed the problem by not using $0 and $1. Instead I used global variables I defined myself.

Below is the code that works:
StrCpy $R0 ""
var /GLOBAL FileHandle
var /GLOBAL FileName
StrCpy $FileHandle ""
StrCpy $FileName ""
FindFirst $FileHandle $FileName $INSTDIR\server\webapps\*.xml
FindContextsLoop:
StrCmp $FileName "" FindContextsLoopDone
${UnStrRep} $R0 "$FileName" ".xml" ""
MessageBox MB_OK "About to Delete Virtual Directory: $R0"
!insertmacro DELETE_VIRTUAL_DIRECTORY $R0
MessageBox MB_OK "Just deleted Virtual Directory: $R0"
MessageBox MB_OK "FileHandle = $FileHandle"
MessageBox MB_OK "FileName = $FileName"
ClearErrors
MessageBox MB_OK "Just completed ClearErrors instruction."
MessageBox MB_OK "About to execute FindNext instruction."
FindNext $FileHandle $FileName
MessageBox MB_OK "Just completed FindNext instruction."
IfErrors 0 FindContextsLoop
FindContextsLoopDone:
FindClose $FileHandle

Thanks for your help.
fperez is offline   Reply With Quote
Reply
Go Back   Winamp 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