Reference/FindFirst: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
m (Fixed inconsistent reference from FileClose to FindClose)
 
Line 3: Line 3:
  user_var(handle output) user_var(filename output) filespec
  user_var(handle output) user_var(filename output) filespec


Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with [[Reference/FindNext|FindNext]] and [[Reference/FileClose|FileClose]]. Note that the filename output is without path.
Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with [[Reference/FindNext|FindNext]] and [[Reference/FindClose|FindClose]]. Note that the filename output is without path.


<highlight-nsis>FindFirst $0 $1 $INSTDIR\*.txt
<highlight-nsis>FindFirst $0 $1 $INSTDIR\*.txt

Latest revision as of 00:12, 1 September 2016

FindFirst

user_var(handle output) user_var(filename output) filespec

Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with FindNext and FindClose. Note that the filename output is without path.

FindFirst $0 $1 $INSTDIR\*.txt
loop:
  StrCmp $1 "" done
  DetailPrint $1
  FindNext $0 $1
  Goto loop
done:
FindClose $0

Command introduced with NSIS v1.60