Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Encapsulated IfFileExists (http://forums.winamp.com/showthread.php?t=297457)

Salinn 16th September 2008 08:24

Encapsulated IfFileExists
 
Hi,

Is it possible to encapsulate multiple IfFileExists?

I`m trying to search for multiple files on the user`s hdd, and if one of them isn`t there, to search a messagebox.

Another example is, searching for multiple files (that are in multiple directories and to search for some registry keys. If one of these (Files or Registry Keys) isn`t there, to show the messagebox.

I tried to make something like this:

code:

IfFileExists "C:\Test.txt" aha test

aha:
MessageBox MB_OK "Test.txt exists"
test:
IfFileExists "C:\Test2.txt" works not
works:
MessageBox MB_OK "Test.txt does not exists but Test2.txt exists"
not:
MessageBox MB_OK "Neither Test.txt or Test2.txt exists"



But it seems that this isn`t working.

I tried with registry too but after it check that the file exists it jumps the registry checking.

Any suggestions?

MSG 16th September 2008 09:20

You forgot to jump out of each block.
PHP Code:

IfFileExists "C:\Test.txt" aha test

aha
:
  
MessageBox MB_OK "Test.txt exists"
  
goto end
test
:
  
IfFileExists "C:\Test2.txt" works not
  works
:
    
MessageBox MB_OK "Test.txt does not exists but Test2.txt exists"
    
goto end
  not
:
    
MessageBox MB_OK "Neither Test.txt or Test2.txt exists"
end

I'd advise you to include logiclib.nsh and do this:
PHP Code:

${If} ${FileExists"C:\Test.txt"
  
MessageBox MB_OK "Test.txt exists"
${Else}
  ${If} ${
FileExists}  "C:\Test2.txt"
    
MessageBox MB_OK "Test.txt does not exists but Test2.txt exists"
  
${Else}
    
MessageBox MB_OK "Neither Test.txt or Test2.txt exists"
  
${EndIf}
${EndIf} 


Salinn 16th September 2008 09:54

Thanks for the info.

What if Test.txt exists and Test2.txt doesn`t?

In your example, if he find Test.txt it stops searching for Test2.txt.

How can i do so that it will check both files and if one of them isn`t there it`ll pop a message box?

I must do it for several files so the start is from two :P.

MSG 16th September 2008 10:34

You're looking for ${IfNot} and ${AndIfNot}. See nsis.sourceforge.net/LogicLib or your NSIS\Examples\LogicLib.nsi for examples on what LogicLib can do.

Salinn 16th September 2008 11:25

Ok.

Thanks for helping me.


All times are GMT. The time now is 04:33.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.