added small usage examples

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3703 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-10-10 18:41:43 +00:00
parent 07eb9b6425
commit 38b693f19a
24 changed files with 618 additions and 23 deletions

View file

@ -14,30 +14,66 @@ Opens a file named "filename", and sets the handle output variable with the hand
If no absolute path is specified the current folder will be used. The current folder is the folder set using the last \R{setoutpath}{SetOutPath} instruction. If you have not used \R{setoutpath}{SetOutPath} the current folder is \R{varother}{$EXEDIR}.
\c FileOpen $0 $INSTDIR\file.dat r
\c FileClose $0
\S2{FileRead} FileRead
\c handle user_var(output) [maxlen]
Reads a string from a file opened with FileOpen. The string is read until either a newline (or carriage return newline pair) occurs, or until a null byte is read, or until maxlen is met (if specified). Strings are limited to 1024 characters. If the end of file is read and no more data is available, the output string will be empty, and the error flag will be set.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
\c IfErrors done
\c FileRead $0 $1
\c DetailPrint $1
\c FileClose $0
\c done:
\S2{FileReadByte} FileReadByte
\c handle user_var(output)
Reads a byte from a file opened with FileOpen. The byte is stored in the output as an integer (0-255). If the end of file is read and no more data is available, the output will be empty, and the error flag will be set.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
\c IfErrors done
\c FileReadByte $0 $1
\c FileReadByte $0 $2
\c DetailPrint "$1 $2"
\c FileClose $0
\c done:
\S2{FileSeek} FileSeek
\c handle offset [mode] [user_var(new position)]
Seeks a file opened with FileOpen. If mode is omitted or specified as SET, the file is positioned to "offset". If mode is specified as CUR, then the file pointer is moved by offset. If mode is specified as END, the file pointer is set to a position relative to EOF. If the final parameter "new position" is specified, the new file position will be stored to that variable.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat r
\c IfErrors done
\c FileSeek $0 -5 END
\c FileRead $0 $1
\c DetailPrint $1
\c FileClose $0
\c done:
\S2{FileWrite} FileWrite
\c handle string
Writes a string to a file opened with FileOpen. If an error occurs writing, the error flag will be set.
\c ClearErrors
\c FileOpen $0 $INSTDIR\file.dat w
\c IfErrors done
\c FileWrite $0 "some text"
\c FileClose $0
\c done:
\S2{FileWriteByte} FileWriteByte
\c handle string
@ -61,8 +97,16 @@ Closes a search opened with FindFirst.
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.
\c FindFirst $0 $1 $INSTDIR\*.txt
\c loop:
\c StrCmp $1 "" done
\c DetailPrint $1
\c FindNext $0 $1
\c Goto loop
\c done:
\S2{FindNext} FindNext
\c handle user_var(filename_output)
Continues a search began with FindFirst. handle should be the handle_output_variable returned by FindFirst. If the search is completed (there are no more files), filename_output is set to empty, and the error flag is set. Note that the filename output is without path.
Continues a search began with FindFirst. handle should be the handle_output_variable returned by FindFirst. If the search is completed (there are no more files), filename_output is set to empty, and the error flag is set. Note that the filename output is without path.