<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Useful Headers</title> <meta name="generator" content="Halibut version 1.0 (NSIS Custom Build) xhtml-backend" /> <link rel="stylesheet" href="style.css" type='text/css' /> </head> <body> <p><a href='AppendixD.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixF.html'>Next</a></p> <ul> <li><a class="btitle" href="AppendixE.html#E"><b>Appendix E: </b>Useful Headers</a></li> <ul> <li><a href="AppendixE.html#E.1">File Functions Header</a></li> <ul> <li><a href="AppendixE.html#E.1.1">Introduction</a></li> <li><a href="AppendixE.html#E.1.2">Locate</a></li> <li><a href="AppendixE.html#E.1.3">GetSize</a></li> <li><a href="AppendixE.html#E.1.4">DriveSpace</a></li> <li><a href="AppendixE.html#E.1.5">GetDrives</a></li> <li><a href="AppendixE.html#E.1.6">GetTime</a></li> <li><a href="AppendixE.html#E.1.7">GetFileAttributes</a></li> <li><a href="AppendixE.html#E.1.8">GetFileVersion</a></li> <li><a href="AppendixE.html#E.1.9">GetExeName</a></li> <li><a href="AppendixE.html#E.1.10">GetExePath</a></li> <li><a href="AppendixE.html#E.1.11">GetParameters</a></li> <li><a href="AppendixE.html#E.1.12">GetOptions</a></li> <li><a href="AppendixE.html#E.1.13">GetOptionsS</a></li> <li><a href="AppendixE.html#E.1.14">GetRoot</a></li> <li><a href="AppendixE.html#E.1.15">GetParent</a></li> <li><a href="AppendixE.html#E.1.16">GetFileName</a></li> <li><a href="AppendixE.html#E.1.17">GetBaseName</a></li> <li><a href="AppendixE.html#E.1.18">GetFileExt</a></li> <li><a href="AppendixE.html#E.1.19">BannerTrimPath</a></li> <li><a href="AppendixE.html#E.1.20">DirState</a></li> <li><a href="AppendixE.html#E.1.21">RefreshShellIcons</a></li> </ul> <li><a href="AppendixE.html#E.2">Text Functions Header</a></li> <ul> <li><a href="AppendixE.html#E.2.1">Introduction</a></li> <li><a href="AppendixE.html#E.2.2">LineFind</a></li> <li><a href="AppendixE.html#E.2.3">LineRead</a></li> <li><a href="AppendixE.html#E.2.4">FileReadFromEnd</a></li> <li><a href="AppendixE.html#E.2.5">LineSum</a></li> <li><a href="AppendixE.html#E.2.6">FileJoin</a></li> <li><a href="AppendixE.html#E.2.7">TextCompare</a></li> <li><a href="AppendixE.html#E.2.8">TextCompareS</a></li> <li><a href="AppendixE.html#E.2.9">ConfigRead</a></li> <li><a href="AppendixE.html#E.2.10">ConfigReadS</a></li> <li><a href="AppendixE.html#E.2.11">ConfigWrite</a></li> <li><a href="AppendixE.html#E.2.12">ConfigWriteS</a></li> <li><a href="AppendixE.html#E.2.13">FileRecode</a></li> <li><a href="AppendixE.html#E.2.14">TrimNewLines</a></li> </ul> <li><a href="AppendixE.html#E.3">Word Functions Header</a></li> <ul> <li><a href="AppendixE.html#E.3.1">Introduction</a></li> <li><a href="AppendixE.html#E.3.2">WordFind</a></li> <li><a href="AppendixE.html#E.3.3">WordFindS</a></li> <li><a href="AppendixE.html#E.3.4">WordFind2X</a></li> <li><a href="AppendixE.html#E.3.5">WordFind2XS</a></li> <li><a href="AppendixE.html#E.3.6">WordFind3X</a></li> <li><a href="AppendixE.html#E.3.7">WordFind3XS</a></li> <li><a href="AppendixE.html#E.3.8">WordReplace</a></li> <li><a href="AppendixE.html#E.3.9">WordReplaceS</a></li> <li><a href="AppendixE.html#E.3.10">WordAdd</a></li> <li><a href="AppendixE.html#E.3.11">WordAddS</a></li> <li><a href="AppendixE.html#E.3.12">WordInsert</a></li> <li><a href="AppendixE.html#E.3.13">WordInsertS</a></li> <li><a href="AppendixE.html#E.3.14">StrFilter</a></li> <li><a href="AppendixE.html#E.3.15">StrFilterS</a></li> <li><a href="AppendixE.html#E.3.16">VersionCompare</a></li> <li><a href="AppendixE.html#E.3.17">VersionConvert</a></li> </ul> </ul> </ul> <a name="E"></a><h1>Appendix E: Useful Headers</h1> <a name="E.1"></a><h2>E.1 File Functions Header</h2> <a name="E.1.1"></a><h3>E.1.1 Introduction</h3> <p>Include header:</p> <pre>!include "FileFunc.nsh" </pre> <p>Call functions:</p> <pre>Section Install ${GetFileExt} "C:\My Downloads\Index.html" $R0 ; $R0="html" SectionEnd </pre> <pre>Section un.Install ${GetParent} "C:\My Downloads\Index.html" $R0 ; $R0="C:\My Downloads" SectionEnd </pre> <a name="E.1.2"></a><h3>E.1.2 Locate</h3> <ul> <li>Find files, directories and empty directories with mask and size options.</li></ul> <p><b>Syntax:</b></p> <pre>${Locate} "[Path]" "[Options]" "Function" </pre> <pre>"[Path]" ; Disk or Directory ; "[Options]" ; /L=[FD|F|D|DE|FDE] ; /L=FD - Locate Files and Directories (default) ; /L=F - Locate Files only ; /L=D - Locate Directories only ; /L=DE - Locate Empty Directories only ; /L=FDE - Locate Files and Empty Directories ; /M=[mask] ; /M=*.* - Locate all (default) ; /M=*.doc - Locate Work.doc, 1.doc ... ; /M=Pho* - Locate PHOTOS, phone.txt ... ; /M=win???.exe - Locate winamp.exe, winver.exe ... ; /M=winamp.exe - Locate winamp.exe only ; /S=No:No[B|K|M|G] ; /S= - Don't locate file size (faster) (default) ; /S=0:0B - Locate only files of 0 Bytes exactly ; /S=5:9K - Locate only files of 5 to 9 Kilobytes ; /S=:10M - Locate only files of 10 Megabyte or less ; /S=1G - Locate only files of 1 Gigabyte or more ; /G=[1|0] ; /G=1 - Locate with subdirectories (default) ; /G=0 - Locate without subdirectories ; /B=[0|1] ; /B=0 - Banner isn't used (default) ; /B=1 - Banner is used. Callback when function ; start to search in new directory "Function" ; Callback function when found Function "Function" 	; $R9 "path\name" 	; $R8 "path" 	; $R7 "name" 	; $R6 "size" ($R6="" if directory, $R6="0" if file with /S=) 	; $R0-$R5 are not used (save data in them). 	; ... 	Push $var ; If $var="StopLocate" Then exit from function FunctionEnd </pre> <p><b>Note:</b> <br>- Error flag if disk or directory isn't exist <br>- Error flag if syntax error <br>- See also <a href="http://nsis.sourceforge.net/Locate_plugin">Locate plugin</a></p> <p><b>Example (Find one file):</b></p> <pre>Section 	${Locate} "C:\ftp" "/L=F /M=RPC DCOM.rar /S=1K" "Example1" 	; 'RPC DCOM.rar' file in 'C:\ftp' with size 1 Kb or more 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	MessageBox MB_OK "$$R0=$R0" SectionEnd Function Example1 	StrCpy $R0 $R9 	; $R0="C:\ftp\files\RPC DCOM.rar" 	MessageBox MB_YESNO '$R0$\n$\nFind next?' IDYES +2 	StrCpy $0 StopLocate 	Push $0 FunctionEnd </pre> <p><b>Example (Write results to a text file):</b></p> <pre>Section 	GetTempFileName $R0 	FileOpen $R1 $R0 w 	${Locate} "C:\ftp" "/S=:2M /G=0" "Example2" 	; folders and all files with size 2 Mb or less 	; don't scan subdirectories 	FileClose $R1 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	Exec '"notepad.exe" "$R0"' SectionEnd Function Example2 	StrCmp $R6 '' 0 +3 	FileWrite $R1 "Directory=$R9$\r$\n" 	goto +2 	FileWrite $R1 "File=$R9 Size=$R6 Mb$\r$\n" 	Push $0 FunctionEnd </pre> <p><b>Example (Write results to an INI file):</b></p> <pre>Section 	GetTempFileName $R0 	${Locate} "C:\ftp" "/L=F /S=0K" "Example3" 	; all files in 'C:\ftp' with size detect in Kb 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	Exec '"notepad.exe" "$R0"' SectionEnd Function Example3 	WriteINIStr $R0 "$R8" "$R7" "$R6 Kb" 	Push $0 FunctionEnd </pre> <p><b>Example (Delete empty directories):</b></p> <pre>Section 	StrCpy $R2 0 	StrCpy $R3 0 	loop: 	StrCpy $R1 0 	${Locate} "C:\ftp" "/L=DE" "Example4" 	IntOp $R3 $R3 + 1 	IntOp $R2 $R2 + $R1 	StrCmp $R0 StopLocate +2 	StrCmp $R1 0 0 loop 	IfErrors 0 +2 	MessageBox MB_OK 'error' IDOK +2 	MessageBox MB_OK '$R2 directories were removed$\n$R3 loops' SectionEnd Function Example4 	MessageBox MB_YESNOCANCEL 'Delete empty "$R9"?' IDNO end IDCANCEL cancel 	RMDir $R9 	IntOp $R1 $R1 + 1 	goto end 	cancel: 	StrCpy $R0 StopLocate 	end: 	Push $R0 FunctionEnd </pre> <p><b>Example (Move all files into one folder):</b></p> <pre>Section 	StrCpy $R0 "C:\ftp" ;Directory move from 	StrCpy $R1 "C:\ftp2" ;Directory move into 	StrCpy $R2 0 	StrCpy $R3 0 	${Locate} "$R0" "/L=F" "Example5" 	IfErrors 0 +2 	MessageBox MB_OK 'error' IDOK +4 	StrCmp $R3 0 0 +2 	MessageBox MB_OK '$R2 files were moved' IDOK +2 	MessageBox MB_OK '$R2 files were moved$\n$R3 files were NOT moved' SectionEnd Function Example5 	StrCmp $R8 $R1 +6 	IfFileExists '$R1\$R7' +4 	Rename $R9 '$R1\$R7' 	IntOp $R2 $R2 + 1 	goto +2 	IntOp $R3 $R3 + 1 	Push $0 FunctionEnd </pre> <p><b>Example (Copy files with log):</b></p> <pre>Section 	StrCpy $R0 "C:\ftp" ;Directory copy from 	StrCpy $R1 "C:\ftp2" ;Directory copy into 	StrLen $R2 $R0 	GetTempFileName $0 	FileOpen $R3 $0 w 	${Locate} "$R0" "/L=FDE" "Example6" 	FileClose $R3 	IfErrors 0 +2 	MessageBox MB_OK 'error' 	Exec '"notepad.exe" "$0"' ;view log SectionEnd Function Example6 	StrCpy $1 $R8 '' $R2 	StrCmp $R6 '' 0 +3 	CreateDirectory '$R1$1\$R7' 	goto end 	CreateDirectory '$R1$1' 	CopyFiles /SILENT $R9 '$R1$1' 	IfFileExists '$R1$1\$R7' 0 +3 	FileWrite $R3 "-old:$R9 -new:$R1$1\$R7 -success$\r$\n" 	goto +2 	FileWrite $R3 "-old:$R9 -new:$R1$1\$R7 -failed$\r$\n" 	end: 	Push $0 FunctionEnd </pre> <p><b>Example (Recreate directory structure):</b></p> <pre>Section 	StrCpy $R0 "C:\ftp" ;Directory structure from 	StrCpy $R1 "C:\ftp2" ;Directory structure into 	StrLen $R2 $R0 	${Locate} "$R0" "/L=D" "Example7" 	IfErrors 0 +2 	MessageBox MB_OK 'error' SectionEnd Function Example7 	StrCpy $1 $R9 '' $R2 	CreateDirectory '$R1$1' 	Push $0 FunctionEnd </pre> <p><b>Example (Locate with banner - <a href="http://nsis.sourceforge.net/Nxs_plug-in">NxS plugin</a> required):</b></p> <pre>Section 	nxs::Show /NOUNLOAD `$(^Name) Setup` /top `Setup searching something$\r$\nPlease wait... If you can..` /h 1 /can 1 /end 	${Locate} "C:\WINDOWS" "/L=F /M=*.inf /B=1" "Example8" 	nxs::Destroy SectionEnd Function Example8 	StrCmp $R0 $R8 abortcheck 	StrCpy $R0 $R8 	nxs::Update /NOUNLOAD /sub "$R8" /pos 78 /end 	abortcheck: 	nxs::HasUserAborted /NOUNLOAD 	Pop $0 	StrCmp $0 1 0 +2 	StrCpy $0 StopLocate 	StrCmp $R9 '' end 	;... 	end: 	Push $0 FunctionEnd </pre> <a name="E.1.3"></a><h3>E.1.3 GetSize</h3> <ul> <li>Find the size of a file, files mask or directory.</li><li>Find the sum of the files, directories and subdirectories.</li></ul> <p><b>Syntax:</b></p> <pre>${GetSize} "[Path]" "[Options]" $var1 $var2 $var3 </pre> <pre>"[Path]" ; Disk or Directory ; "[Options]" ; /M=[mask] ; /M=*.* - Find all (default) ; /M=*.doc - Find Work.doc, 1.doc ... ; /M=Pho* - Find PHOTOS, phone.txt ... ; /M=win???.exe - Find winamp.exe, winver.exe ... ; /M=winamp.exe - Find winamp.exe only ; /S=No:No[B|K|M|G] ; /S= - Don't find file size (faster) (default) ; /S=0:0B - Find only files of 0 Bytes exactly ; /S=5:9K - Find only files of 5 to 9 Kilobytes ; /S=:10M - Find only files of 10 Megabyte or less ; /S=1G - Find only files of 1 Gigabyte or more ; /G=[1|0] ; /G=1 - Find with subdirectories (default) ; /G=0 - Find without subdirectories ; $var1 ; Result1: Size $var2 ; Result2: Sum of files $var3 ; Result3: Sum of directories </pre> <p><b>Note:</b> <br>- Error flag if disk or directory isn't exist <br>- Error flag if syntax error <br>- See also <a href="http://nsis.sourceforge.net/Locate_plugin">Locate plugin</a></p> <p><b>Example (1):</b></p> <pre>Section 	; Find file size "C:\WINDOWS\Explorer.exe" in kilobytes 	${GetSize} "C:\WINDOWS" "/M=Explorer.exe /S=0K /G=0" $0 $1 $2 	; $0="220" Kb 	; $1="1" files 	; $2="" directories 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd </pre> <p><b>Example (2):</b></p> <pre>Section 	; Find folder size "C:\Installs\Reanimator\Drivers" in megabytes 	${GetSize} "C:\Installs\Reanimator\Drivers" "/S=0M" $0 $1 $2 	; $0="132" Mb 	; $1="555" files 	; $2="55" directories 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd </pre> <p><b>Example (3):</b></p> <pre>Section 	; Find sum of files and folders "C:\WINDOWS" (no subfolders) 	${GetSize} "C:\WINDOWS" "/G=0" $0 $1 $2 	; $0="" size 	; $1="253" files 	; $2="46" directories 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd </pre> <a name="E.1.4"></a><h3>E.1.4 DriveSpace</h3> <ul> <li>Get total, occupied or free space of the drive.</li></ul> <p><b>Syntax:</b></p> <pre>${DriveSpace} "[Drive]" "[Options]" $var </pre> <pre>"[Drive]" ; Disk to check ; "[Options]" ; /D=[T|O|F] ; /D=T - Total space (default) ; /D=O - Occupied space ; /D=F - Free space ; /S=[B|K|M|G] ; /S=B - size in Bytes (default) ; /S=K - size in Kilobytes ; /S=M - size in Megabytes ; /S=G - size in Gigabytes ; $var ; Result: Size </pre> <p><b>Note:</b> <br>- Error flag if disk isn't exist or not ready <br>- Error flag if syntax error</p> <p><b>Example:</b></p> <pre>Section 	${DriveSpace} "C:\" "/D=F /S=M" $R0 	; $R0="2530" megabytes free on drive C: SectionEnd </pre> <a name="E.1.5"></a><h3>E.1.5 GetDrives</h3> <ul> <li>Find all available drives in the system.</li></ul> <p><b>Syntax:</b></p> <pre>${GetDrives} "[Option]" "Function" </pre> <pre>"[Option]" ; [FDD+HDD+CDROM+NET+RAM] ; FDD Floppy Disk Drives ; HDD Hard Disk Drives ; CDROM CD-ROM Drives ; NET Network Drives ; RAM RAM Disk Drives ; ; [ALL] ; Find all drives by letter (default) ; "Function" ; Callback function when found Function "Function" 	; $9 "drive letter" (a:\ c:\ ...) 	; $8 "drive type" (FDD HDD ...) 	; $R0-$R9 are not used (save data in them). 	; ... 	Push $var ; If $var="StopGetDrives" Then exit from function FunctionEnd </pre> <p><b>Example1:</b></p> <pre>Section 	${GetDrives} "FDD+CDROM" "Example1" SectionEnd Function Example1 	MessageBox MB_OK "$9 ($8 Drive)" 	Push $0 FunctionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${GetDrives} "ALL" "Example2" SectionEnd Function Example2 	MessageBox MB_OK "$9 ($8 Drive)" 	Push $0 FunctionEnd </pre> <p><b>Example3 (Get type of drive):</b></p> <pre>Section 	StrCpy $R0 "D:\" ;Drive letter 	StrCpy $R1 "invalid" 	${GetDrives} "ALL" "Example3" 	MessageBox MB_OK "Type of drive $R0 is $R1" SectionEnd Function Example3 	StrCmp $9 $R0 0 +3 	StrCpy $R1 $8 	StrCpy $0 StopGetDrives 	Push $0 FunctionEnd </pre> <a name="E.1.6"></a><h3>E.1.6 GetTime</h3> <ul> <li>Get local or system time.</li><li>Get file time (access, creation and modification).</li></ul> <p><b>Syntax:</b></p> <pre>${GetTime} "[File]" "[Option]" $var1 $var2 $var3 $var4 $var5 $var6 $var7 </pre> <pre>"[File]" ; Ignored if "L" or "LS" ; "[Option]" ; [Options] ; L Local time ; A last Access file time ; C Creation file time ; M Modification file time ; LS System time (UTC) ; AS last Access file time (UTC) ; CS Creation file time (UTC) ; MS Modification file time (UTC) ; $var1 ; Result1: day $var2 ; Result2: month $var3 ; Result3: year $var4 ; Result4: day of week name $var5 ; Result5: hour $var6 ; Result6: minute $var7 ; Result7: seconds </pre> <p><b>Note:</b> <br>- Error flag if file isn't exist <br>- Error flag if syntax error <br>- See also <a href="http://nsis.sourceforge.net/Time_plugin">Time plugin</a></p> <p><b>Example (Get local time):</b></p> <pre>Section 	${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 	; $0="01" day 	; $1="04" month 	; $2="2005" year 	; $3="Friday" day of week name 	; $4="16" hour 	; $5="05" minute 	; $6="50" seconds 	MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' SectionEnd </pre> <p><b>Example (Get file time):</b></p> <pre>Section 	${GetTime} "$WINDIR\Explorer.exe" "C" $0 $1 $2 $3 $4 $5 $6 	; $0="12" day 	; $1="10" month 	; $2="2004" year 	; $3="Tuesday" day of week name 	; $4="2" hour 	; $5="32" minute 	; $6="03" seconds 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' SectionEnd </pre> <p><b>Example (Get system time):</b></p> <pre>Section 	${GetTime} "" "LS" $0 $1 $2 $3 $4 $5 $6 	; $0="01" day 	; $1="04" month 	; $2="2005" year 	; $3="Friday" day of week name 	; $4="11" hour 	; $5="05" minute 	; $6="50" seconds 	MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' SectionEnd </pre> <p><b>Example (Convert time to 12-hour format AM/PM):</b></p> <pre>Section 	${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 	StrCmp $4 0 0 +3 	StrCpy $4 12 	goto +3 	StrCmp $4 12 +5 	IntCmp $4 12 0 0 +3 	StrCpy $7 AM 	goto +3 	IntOp $4 $4 - 12 	StrCpy $7 PM 	MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6 $7' SectionEnd </pre> <a name="E.1.7"></a><h3>E.1.7 GetFileAttributes</h3> <ul> <li>Get attributes of file or directory.</li></ul> <p><b>Syntax:</b></p> <pre>${GetFileAttributes} "[File]" "[Attributes]" $var </pre> <pre>"[File]" ; File or directory ; "[Attributes]" ; "ALL" (default) ; -all attributes of file combined with "|" to output ; ; "READONLY|HIDDEN|SYSTEM|DIRECTORY|ARCHIVE| ; DEVICE|NORMAL|TEMPORARY|SPARSE_FILE|REPARSE_POINT| ; COMPRESSED|OFFLINE|NOT_CONTENT_INDEXED|ENCRYPTED" ; -file must have specified attributes ; $var ; Result: ; $var=attr1|attr2|... (if used "ALL") ; $var=1 file has specified attributes ; $var=0 file has no specified attributes </pre> <p><b>Note:</b> <br>- Error flag if file doesn't exist</p> <p><b>Example1:</b></p> <pre>Section 	${GetFileAttributes} "C:\MSDOS.SYS" "ALL" $R0 	; $R0=READONLY|HIDDEN|SYSTEM|ARCHIVE SectionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${GetFileAttributes} "C:\MSDOS.SYS" "SYSTEM|HIDDEN" $R0 	; $R0=1 SectionEnd </pre> <p><b>Example3:</b></p> <pre>Section 	${GetFileAttributes} "C:\MSDOS.SYS" "NORMAL" $R0 	; $R0=0 SectionEnd </pre> <a name="E.1.8"></a><h3>E.1.8 GetFileVersion</h3> <ul> <li>Get version information from executable file.</li></ul> <p><b>Syntax:</b></p> <pre>${GetFileVersion} "[Executable]" $var </pre> <pre>"[Executable]" ; Executable file (*.exe *.dll ...) $var ; Result: Version number </pre> <p><b>Note:</b> <br>- Error flag if file doesn't exist <br>- Error flag if file doesn't contain version information</p> <p><b>Example:</b></p> <pre>Section 	${GetFileVersion} "C:\ftp\program.exe" $R0 	; $R0="1.1.0.12" SectionEnd </pre> <a name="E.1.9"></a><h3>E.1.9 GetExeName</h3> <ul> <li>Get installer filename (with valid case for Windows 98/Me).</li></ul> <p><b>Syntax:</b></p> <pre>${GetExeName} $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetExeName} $R0 	; $R0="C:\ftp\program.exe" SectionEnd </pre> <a name="E.1.10"></a><h3>E.1.10 GetExePath</h3> <ul> <li>Get installer pathname ($EXEDIR with valid case for Windows 98/Me).</li></ul> <p><b>Syntax:</b></p> <pre>${GetExePath} $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetExePath} $R0 	; $R0="C:\ftp" SectionEnd </pre> <a name="E.1.11"></a><h3>E.1.11 GetParameters</h3> <ul> <li>Get command line parameters.</li></ul> <p><b>Syntax:</b></p> <pre>${GetParameters} $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetParameters} $R0 	; $R0="[parameters]" SectionEnd </pre> <a name="E.1.12"></a><h3>E.1.12 GetOptions</h3> <ul> <li>Get options from command line parameters.</li></ul> <p><b>Syntax:</b></p> <pre>${GetOptions} "[Parameters]" "[Option]" $var </pre> <pre>"[Parameters]" ; command line parameters ; "[Option]" ; option name ; $var ; Result: option string </pre> <p><b>Note:</b> <br>- Error flag if option not found <br>- First option symbol it is delimiter</p> <p><b>Example1:</b></p> <pre>Section 	${GetOptions} "/S /T" "/T" $R0 	IfErrors 0 +2 	MessageBox MB_OK "Not found" IDOK +2 	MessageBox MB_OK "Found" SectionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${GetOptions} "-INSTDIR=C:\Program Files\Common Files -SILENT=yes" "-INSTDIR=" $R0 	;$R0=C:\Program Files\Common Files SectionEnd </pre> <p><b>Example3:</b></p> <pre>Section 	${GetOptions} '/SILENT=yes /INSTDIR="C:/Program Files/Common Files" /ADMIN=password' "/INSTDIR=" $R0 	;$R0=C:/Program Files/Common Files SectionEnd </pre> <p><b>Example4:</b></p> <pre>Section 	${GetOptions} `-SILENT=yes -INSTDIR='"C:/Program Files/Common Files"' -ADMIN=password` "-INSTDIR=" $R0 	;$R0="C:/Program Files/Common Files" SectionEnd </pre> <a name="E.1.13"></a><h3>E.1.13 GetOptionsS</h3> <ul> <li>Same as <a href="AppendixE.html#E.1.12">GetOptions</a>, but case sensitive.</li></ul> <a name="E.1.14"></a><h3>E.1.14 GetRoot</h3> <ul> <li>Get root directory.</li></ul> <p><b>Syntax:</b></p> <pre>${GetRoot} "[FullPath]" $var </pre> <p><b>Example1:</b></p> <pre>Section 	${GetRoot} "C:\Program Files\NSIS" $R0 	; $R0="C:" SectionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${GetRoot} "\\SuperPimp\NSIS\Source\exehead\Ui.c" $R0 	; $R0="\\SuperPimp\NSIS" SectionEnd </pre> <a name="E.1.15"></a><h3>E.1.15 GetParent</h3> <ul> <li>Get parent directory.</li></ul> <p><b>Syntax:</b></p> <pre>${GetParent} "[PathString]" $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetParent} "C:\Program Files\Winamp\uninstwa.exe" $R0 	; $R0="C:\Program Files\Winamp" SectionEnd </pre> <a name="E.1.16"></a><h3>E.1.16 GetFileName</h3> <ul> <li>Get last part from directory path.</li></ul> <p><b>Syntax:</b></p> <pre>${GetFileName} "[PathString]" $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetFileName} "C:\Program Files\Winamp\uninstwa.exe" $R0 	; $R0="uninstwa.exe" SectionEnd </pre> <a name="E.1.17"></a><h3>E.1.17 GetBaseName</h3> <ul> <li>Get file name without extension.</li></ul> <p><b>Syntax:</b></p> <pre>${GetBaseName} "[FileString]" $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetBaseName} "C:\ftp\program.exe" $R0 	; $R0="program" SectionEnd </pre> <a name="E.1.18"></a><h3>E.1.18 GetFileExt</h3> <ul> <li>Get extension of file.</li></ul> <p><b>Syntax:</b></p> <pre>${GetFileExt} "[FileString]" $var </pre> <p><b>Example:</b></p> <pre>Section 	${GetFileExt} "C:\ftp\program.exe" $R0 	; $R0="exe" SectionEnd </pre> <a name="E.1.19"></a><h3>E.1.19 BannerTrimPath</h3> <ul> <li>Trim string path for banner.</li></ul> <p><b>Syntax:</b></p> <pre>${BannerTrimPath} "[PathString]" "[Option]" $var </pre> <pre>"[PathString]" ; ; "[Option]" ; [Length][A|B|C|D] ; ; Length -Maximum string length ; A -Trim center path (default) ; (C:\root\...\third path) ; If A mode not possible Then will be used B mode ; B -Trim right path ; (C:\root\second path\...) ; If B mode not possible Then will be used C mode ; C -Trim right string ; (C:\root\second path\third p...) ; D -Trim right string + filename ; (C:\root\second p...\third path) ; If D mode not possible Then will be used C mode ; $var ; Result: Trimmed path </pre> <p><b>Example:</b></p> <pre>Section 	${BannerTrimPath} "C:\Server\Documents\Terminal\license.htm" "35A" $R0 	;$R0=C:\Server\...\Terminal\license.htm SectionEnd </pre> <p><b>Example (Banner plugin):</b></p> <pre>!include "WinMessages.nsh" !include "FileFunc.nsh" Section 	Banner::show "Starting..." 	Banner::getWindow 	Pop $R1 	${Locate} "$WINDIR" "/L=F /M=*.* /B=1" "LocateCallback" 	Banner::destroy SectionEnd Function LocateCallback 	StrCmp $R0 $R8 code 	StrCpy $R0 $R8 	${BannerTrimPath} "$R8" "38B" $R8 	GetDlgItem $1 $R1 1030 	SendMessage $1 ${WM_SETTEXT} 0 "STR:$R8" 	code: 	StrCmp $R9 '' end 	;... 	end: 	Push $0 FunctionEnd </pre> <p><b>Example (<a href="http://nsis.sourceforge.net/Nxs_plug-in">NxS plugin</a>):</b></p> <pre>!include "FileFunc.nsh" Section 	nxs::Show /NOUNLOAD `$(^Name) Setup`\ 	 /top `Setup searching something$\nPlease wait$\nIf you can...`\ 	 /h 1 /can 1 /end 	${Locate} "$WINDIR" "/L=F /M=*.* /B=1" "LocateCallback" 	nxs::Destroy SectionEnd Function LocateCallback 	StrCmp $R0 $R8 abortcheck 	StrCpy $R0 $R8 	${BannerTrimPath} "$R8" "55A" $R8 	nxs::Update /NOUNLOAD /sub "$R8" /pos 78 /end 	abortcheck: 	nxs::HasUserAborted /NOUNLOAD 	Pop $0 	StrCmp $0 1 0 +2 	StrCpy $0 StopLocate 	StrCmp $R9 '' end 	;... 	end: 	Push $0 FunctionEnd </pre> <a name="E.1.20"></a><h3>E.1.20 DirState</h3> <ul> <li>Check directory full, empty or not exist.</li></ul> <p><b>Syntax:</b></p> <pre>${DirState} "[path]" $var </pre> <pre>"[path]" ; Directory $var ; Result: ; $var=0 (empty) ; $var=1 (full) ; $var=-1 (directory not found) </pre> <p><b>Example:</b></p> <pre>Section 	${DirState} "$TEMP" $R0 	; $R0="1" directory is full SectionEnd </pre> <a name="E.1.21"></a><h3>E.1.21 RefreshShellIcons</h3> <ul> <li>After changing file associations, you can call this function to refresh the shell immediately.</li></ul> <p><b>Syntax:</b></p> <pre>${RefreshShellIcons} </pre> <p><b>Example:</b></p> <pre>Section 	WriteRegStr HKCR "Winamp.File\DefaultIcon" "" "$PROGRAMFILES\Winamp\WINAMP.EXE,2" 	${RefreshShellIcons} SectionEnd </pre> <a name="E.2"></a><h2>E.2 Text Functions Header</h2> <a name="E.2.1"></a><h3>E.2.1 Introduction</h3> <p>Include header:</p> <pre>!include "TextFunc.nsh" </pre> <p>Call functions:</p> <pre>Section Install 	${LineRead} "C:\a.log" "-1" $R0 	; $R0="Last line$\r$\n" SectionEnd </pre> <pre>Section un.Install 	${TrimNewLines} "Last line$\r$\n" $R0 	; $R0="Last line" SectionEnd </pre> <a name="E.2.2"></a><h3>E.2.2 LineFind</h3> <ul> <li>Find specified lines in text file, and edit or view these lines in callback function.</li></ul> <p><b>Syntax:</b></p> <pre>${LineFind} "[File1]" "[File2|/NUL]" "[LineNumbers]" "Function" </pre> <pre>"[File1]" ; Input text file ; "[File2|/NUL]" ; [File2] ; Output text file ; If empty then File2=File1 ; [/NUL] ; No output text file (only read File1) ; "[LineNumbers]" ; [No|-No|No:No|{No}|{-No}|{No:No}] ; 1:-1 all lines to change (default) ; 2 second line from start ; -3 third line from end ; 5:9 range of lines from 5 to 9 ; {2} only second line from start to output ; {-3} only third line from end to output ; {5:9} only range of lines from 5 to 9 to output ; "Function" ; Callback function for specified lines Function "Function" 	; $R9 current line 	; $R8 current line number 	; $R7 current line negative number 	; $R6 current range of lines 	; $R5 handle of a file opened to read 	; $R4 handle of a file opened to write ($R4="" if "/NUL") 	; you can use any string functions 	; $R0-$R3 are not used (save data in them). 	; ... 	Push $var ; If $var="StopLineFind" Then exit from function 	 ; If $var="SkipWrite" Then skip current line (ignored if "/NUL") FunctionEnd </pre> <p><b>Note:</b> <br>- Error flag if input file doesn't exist <br>- Error flag if output file path doesn't exist <br>- Ranges must be specified on growth (2 4:5 9:-8 -5:-4 -2:-1) <br>- Output file will not be updated if no changes made.</p> <p><b>Example1 (delete first two symbols):</b></p> <pre>Section 	${LineFind} "C:\a.log" "C:\a-edited.log" "3:-1" "Example1" 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example1 	${TrimNewLines} '$R9' $R9 	StrCpy $R9 $R9 '' 2 	StrCpy $R9 '$R9$\r$\n' 	;start from 3 line and delete first two symbols 	Push $0 FunctionEnd </pre> <p><b>Example2 (show changed lines):</b></p> <pre>Section 	${LineFind} "C:\a.log" "a.log" "{5:12 15 -6:-5 -1}" "Example2" 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example2 	${TrimNewLines} '$R9' $R9 	StrCpy $R9 "$R9 ~Changed line ($R8)~$\r$\n" 	Push $0 FunctionEnd </pre> <p><b>Example3 (delete lines):</b></p> <pre>Section 	${LineFind} "C:\a.log" "\logs\a.log" "2:3 10:-5 -3:-2" "Example3" 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example3 	StrCpy $0 SkipWrite 	Push $0 FunctionEnd </pre> <p><b>Example4 (insert lines):</b></p> <pre>Section 	${LineFind} "C:\a.log" "" "10" "Example4 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example4 	FileWrite $R4 "---First Line---$\r$\n" 	FileWrite $R4 "---Second Line ...---$\r$\n" 	Push $0 FunctionEnd </pre> <p><b>Example5 (replace in file with count of changes - "WordFunc.nsh" required):</b></p> <pre>!include "WordFunc.nsh" Section 	StrCpy $R0 0 	${LineFind} "C:\a.log" "C:\logs\a.log" "1:-1" "Example5" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	MessageBox MB_OK "Changed lines=$R0" SectionEnd Function Example5 	StrCpy $1 $R9 	${WordReplace} '$R9' ' ' '_' '+*' $R9 	StrCmp $1 $R9 +2 	IntOp $R0 $R0 + 1 	;$R0 count of changed lines 	Push $0 FunctionEnd </pre> <p><b>Example6 (line string to cut or delete):</b></p> <pre>Section 	${LineFind} "\a.log" "C:\logs\a.log" "" "Example6" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	MessageBox MB_OK "Processed lines=$R1:$R2" SectionEnd Function Example6 	;(Cut lines from a line to another line (also including that line)) 	StrCmp $R0 finish stop 	StrCmp $R0 start finish 	StrCmp $R9 'Start Line$\r$\n' 0 skip 	StrCpy $R0 start 	StrCpy $R1 $R8 	goto code 	finish: 	StrCmp $R9 'Finish Line$\r$\n' 0 code 	StrCpy $R0 finish 	StrCpy $R2 $R8 	goto code 	skip: 	StrCpy $0 SkipWrite 	goto output 	stop: 	StrCpy $0 StopLineFind 	goto output 	;;(Delete lines from a line to another line (also including that line)) 	; StrCmp $R0 finish code 	; StrCmp $R0 start finish 	; StrCmp $R9 'Start Line$\r$\n' 0 code 	; StrCpy $R0 start 	; StrCpy $R1 $R8 	; goto skip 	; finish: 	; StrCmp $R9 'Finish Line$\r$\n' 0 skip 	; StrCpy $R0 finish 	; StrCpy $R2 $R8 	; skip: 	; StrCpy $0 SkipWrite 	; goto output 	code: 	;... 	output: 	Push $0 FunctionEnd </pre> <p><b>Example7 (read lines):</b></p> <pre>Section 	${LineFind} "C:\a.log" "/NUL" "1:-1" "Example7" 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example7 	MessageBox MB_OKCANCEL '$$R9 "Line"=[$R9]$\n$$R8 "#" =[$R8]' IDOK +2 	StrCpy $0 StopLineFind 	Push $0 FunctionEnd </pre> <a name="E.2.3"></a><h3>E.2.3 LineRead</h3> <ul> <li>Get line in file specified with number.</li></ul> <p><b>Syntax:</b></p> <pre>${LineRead} "[File]" "[LineNumber]" $var </pre> <pre>"[File]" ; Input text file ; "[LineNumber]" ; [No|-No] ; 3 line number from start ; -5 line number from end ; $var ; Result: Line </pre> <p><b>Note:</b> <br>- Error flag if input file doesn't exist <br>- Error flag if line number not found</p> <p><b>Example:</b></p> <pre>Section 	${LineRead} "C:\a.log" "-1" $R0 	; $R0="Last line$\r$\n" SectionEnd </pre> <a name="E.2.4"></a><h3>E.2.4 FileReadFromEnd</h3> <ul> <li>Read text file from end line by line.</li></ul> <p><b>Syntax:</b></p> <pre>${FileReadFromEnd} "[File]" "Function" </pre> <pre>"[File]" ; Input text file "Function" ; Callback function Function "Function" 	; $9 current line 	; $8 current line number 	; $7 current line negative number 	; $R0-$R9 are not used (save data in them). 	; ... 	Push $var ; If $var="StopFileReadFromEnd" Then exit from function FunctionEnd </pre> <p><b>Note:</b> <br>- Error flag if input file doesn't exist</p> <p><b>Example1:</b></p> <pre>Section 	${FileReadFromEnd} "C:\a.log" "Example1" 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example1 	MessageBox MB_OKCANCEL '"Line"=[$9]$\n "#"=[$8]$\n "-#"=[$7]' IDOK +2 	StrCpy $0 StopFileReadFromEnd 	Push $0 FunctionEnd </pre> <p><b>Example2 (Reverse text file):</b></p> <pre>Section 	GetTempFileName $R0 	FileOpen $R1 $R0 w 	${FileReadFromEnd} "C:\a.log" "Example2" 	FileClose $R1 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	Exec '"notepad.exe" "$R0"' SectionEnd Function Example2 	StrCmp $7 -1 0 +5 	StrCpy $1 $9 1 -1 	StrCmp $1 '$\n' +3 	StrCmp $1 '$\r' +2 	StrCpy $9 '$9$\r$\n' 	FileWrite $R1 "$9" 	Push $0 FunctionEnd </pre> <a name="E.2.5"></a><h3>E.2.5 LineSum</h3> <ul> <li>Get sum of lines in text file.</li></ul> <p><b>Syntax:</b></p> <pre>${LineSum} "[File]" $var </pre> <pre>"[File]" ; Input file $var ; Result: Sum of lines </pre> <p><b>Note:</b> <br>- Error flag if input file doesn't exist</p> <p><b>Example:</b></p> <pre>Section 	${LineSum} "C:\a.log" $R0 	; $R0="54" SectionEnd </pre> <a name="E.2.6"></a><h3>E.2.6 FileJoin</h3> <ul> <li>Join two files in one (File1 + File2 = File3).</li></ul> <p><b>Syntax:</b></p> <pre>${FileJoin} "[File1]" "[File2]" "[File3]" </pre> <pre>"[File1]" ; Input File1 "[File2]" ; Input File2 "[File3]" ; Output File3 ; If [File3]="" Then add [File2] to [File1] </pre> <p><b>Note:</b> <br>- Error flag if input files don't exist <br>- Error flag if output file path doesn't exist</p> <p><b>Example1 (Join: a.log + b.log = Z.log):</b></p> <pre>Section 	${FileJoin} "C:\a.log" "C:\logs\b.log" "C:\Z.log" SectionEnd </pre> <p><b>Example2 (Add: a.log + b.log = a.log):</b></p> <pre>Section 	${FileJoin} "C:\a.log" "C:\logs\b.log" "C:\a.log" SectionEnd </pre> <a name="E.2.7"></a><h3>E.2.7 TextCompare</h3> <ul> <li>Compare two text files.</li></ul> <p><b>Syntax:</b></p> <pre>${TextCompare} "[File1]" "[File2]" "[Option]" "Function" </pre> <pre>"[File1]" ; File1 Compare these lines "[File2]" ; File2 Compare with these lines "[Options]" ; (line-by-line): ; FastDiff Compare line N (File1) with line N (File2) ; Call function if Different lines found ; FastEqual Compare line N (File1) with line N (File2) ; Call function if Equal lines found ; (line number independent): ; SlowDiff Compare line N (File1) with all lines (File2) ; Call function if line N (File1) Different ; SlowEqual Compare line N (File1) with all lines (File2) ; Call function if line N (File1) Equal "Function" ; Callback function Function "Function" 	; $9 "Line File1" 	; $8 "Line number" 	; $7 "Line File2" (empty if SlowDiff) 	; $6 "Line number" (empty if SlowDiff) 	; $R0-$R9 are not used (save data in them). 	; ... 	Push $var ; If $var="StopTextCompare" Then exit from function FunctionEnd </pre> <p><b>Note:</b> <br>- Error flag if File1 or File2 doesn't exist <br>- Error flag if syntax error</p> <p><b>Example (Different or Equal):</b></p> <pre>Section 	StrCpy $R0 '' 	${TextCompare} "C:\1.txt" "C:\2.txt" "FastDiff" "Example1" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +4 	StrCmp $R0 NotEqual 0 +2 	MessageBox MB_OK "Files differ" IDOK +2 	MessageBox MB_OK "Files identical" SectionEnd Function Example1 	StrCpy $R0 NotEqual 	StrCpy $0 StopTextCompare 	Push $0 FunctionEnd </pre> <p><b>Example (Compare line-by-line - Different):</b></p> <pre>Section 	StrCpy $R0 'Text1.txt' 	StrCpy $R1 'Text2.txt' 	GetTempFileName $R2 	FileOpen $R3 $R2 w 	FileWrite $R3 "$R0 | $R1$\r$\n" 	${TextCompare} "$R0" "$R1" "FastDiff" "Example2" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	Exec "notepad.exe $R2" FunctionEnd Function Example2 	FileWrite $R3 '$8=$9' 	FileWrite $R3 '$6=$7$\r$\n' 	Push $0 FunctionEnd </pre> <p><b>Example (Compare line-by-line - Equal):</b></p> <pre>Section 	StrCpy $R0 'Text1.txt' 	StrCpy $R1 'Text2.txt' 	GetTempFileName $R2 	FileOpen $R3 $R2 w 	FileWrite $R3 "$R0 | $R1$\r$\n" 	${TextCompare} "$R0" "$R1" "FastEqual" "Example3" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	Exec "notepad.exe $R2" FunctionEnd Function Example3 	FileWrite $R3 '$8|$6=$9' 	Push $0 FunctionEnd </pre> <p><b>Example (Compare all lines - Different):</b></p> <pre>Section 	StrCpy $R0 'Text1.txt' 	StrCpy $R1 'Text2.txt' 	GetTempFileName $R2 	FileOpen $R3 $R2 w 	FileWrite $R3 "$R0 | $R1$\r$\n" 	${TextCompare} "$R0" "$R1" "SlowDiff" "Example4" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK end 	FileWrite $R3 "$\r$\n$R1 | $R0$\r$\n" 	${TextCompare} "$R1" "$R0" "SlowDiff" "Example4" 	FileClose $R3 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK end 	Exec "notepad.exe $R2" 	end: FunctionEnd Function Example4 	FileWrite $R3 '$8=$9' 	Push $0 FunctionEnd </pre> <p><b>Example (Compare all lines - Equal):</b></p> <pre>Section 	StrCpy $R0 'Text1.txt' 	StrCpy $R1 'Text2.txt' 	GetTempFileName $R2 	FileOpen $R3 $R2 w 	FileWrite $R3 "$R0 | $R1$\r$\n" 	${TextCompare} "$R0" "$R1" "SlowEqual" "Example5" 	IfErrors 0 +2 	MessageBox MB_OK "Error" IDOK +2 	Exec "notepad.exe $R2" FunctionEnd Function Example5 	FileWrite $R3 '$8|$6=$9' 	Push $0 FunctionEnd </pre> <p><b>Example (Show variables):</b></p> <pre>Section 	${TextCompare} "C:\1.txt" "C:\2.txt" "FastDiff" "Example6" 	IfErrors 0 +2 	MessageBox MB_OK "Error" SectionEnd Function Example6 	MessageBox MB_OKCANCEL '$$9 "Line File1" =[$9]$\n$$8 "Line #" =[$8]$\n$$7 "Line File2" =[$7]$\n$$6 "Line #" =[$6]' IDOK +2 	StrCpy $0 StopTextCompare 	Push $0 FunctionEnd </pre> <a name="E.2.8"></a><h3>E.2.8 TextCompareS</h3> <ul> <li>Same as <a href="AppendixE.html#E.2.7">TextCompare</a>, but case sensitive.</li></ul> <a name="E.2.9"></a><h3>E.2.9 ConfigRead</h3> <ul> <li>Read value from entry name in config file.</li></ul> <p><b>Syntax:</b></p> <pre>${ConfigRead} "[File]" "[Entry]" $var </pre> <pre>"[File]" ; config file ; "[Entry]" ; entry name ; $var ; Result: Value </pre> <p><b>Note:</b> <br>- Error flag if entry not found <br>- Error flag if file doesn't exist</p> <p><b>Example1:</b></p> <pre>Section 	${ConfigRead} "C:\AUTOEXEC.BAT" "SET winbootdir=" $R0 	;$R0=C:\WINDOWS SectionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${ConfigRead} "C:\apache\conf\httpd.conf" "Timeout " $R0 	;$R0=30 SectionEnd </pre> <a name="E.2.10"></a><h3>E.2.10 ConfigReadS</h3> <ul> <li>Same as <a href="AppendixE.html#E.2.9">ConfigRead</a>, but case sensitive.</li></ul> <a name="E.2.11"></a><h3>E.2.11 ConfigWrite</h3> <ul> <li>Write value from entry name in config file.</li></ul> <p><b>Syntax:</b></p> <pre>${ConfigWrite} "[File]" "[Entry]" "[Value]" $var </pre> <pre>"[File]" ; config file ; "[Entry]" ; entry name ; "[Value]" ; value name ; if "" then delete Entry ; $var ; Result: ; $var=CHANGED Value is written ; $var=DELETED Entry is deleted ; $var=ADDED Entry and Value are added ; $var=SAME Entry and Value already exist </pre> <p><b>Note:</b> <br>- Error flag if file doesn't exist <br>- Error flag if file can't be opened</p> <p><b>Example1:</b></p> <pre>Section 	${ConfigWrite} "C:\AUTOEXEC.BAT" "SET winbootdir=" "D:\WINDOWS" $R0 	;$R0=CHANGED SectionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${ConfigWrite} "C:\apache\conf\httpd.conf" "Timeout " "30" $R0 	;$R0=SAME SectionEnd </pre> <p><b>Example3:</b></p> <pre>Section 	${ConfigWrite} "C:\apache\conf\httpd.conf" "Timeout " "" $R0 	;$R0=DELETED SectionEnd </pre> <a name="E.2.12"></a><h3>E.2.12 ConfigWriteS</h3> <ul> <li>Same as <a href="AppendixE.html#E.2.11">ConfigWrite</a>, but case sensitive.</li></ul> <a name="E.2.13"></a><h3>E.2.13 FileRecode</h3> <ul> <li>Recode text file from DOS to Windows format and vice-versa.</li></ul> <p><b>Syntax:</b></p> <pre>${FileRecode} "[File]" "[Format]" </pre> <pre>"[File]" ; ; "[Format]" ; OemToChar -from DOS to Windows ; CharToOem -from Windows to DOS </pre> <p><b>Note:</b> <br>- Error flag if file doesn't exist <br>- Error flag if syntax error</p> <p><b>Example:</b></p> <pre>Section 	${FileRecode} "C:\SCANDISK.LOG" "CharToOem" SectionEnd </pre> <a name="E.2.14"></a><h3>E.2.14 TrimNewLines</h3> <ul> <li>Trim newlines in a string.</li></ul> <p><b>Syntax:</b></p> <pre>${TrimNewLines} "[string]" $var </pre> <pre>"[string]" ; Input string $var ; Result: String without '$\r' and '$\n' at the end </pre> <p><b>Example:</b></p> <pre>Section 	${TrimNewLines} "Text line$\r$\n" $R0 	; $R0="Text line" SectionEnd </pre> <a name="E.3"></a><h2>E.3 Word Functions Header</h2> <a name="E.3.1"></a><h3>E.3.1 Introduction</h3> <p>Include header:</p> <pre>!include "WordFunc.nsh" </pre> <p>Call functions:</p> <pre>Section Install 	${WordFind} "A--H---S" "-" "+2" $R0 	; $R0="H" SectionEnd </pre> <pre>Section un.Install 	${WordReplace} "A--H---S" "-" "x" "+3*" $R0 	; $R0="A--HxS" SectionEnd </pre> <a name="E.3.2"></a><h3>E.3.2 WordFind</h3> <ul> <li>Multi-features string function.</li></ul> <pre>Strings: "[word+1][delimiter][word+2][delimiter][word+3]..." "[delimiter][word+1][delimiter][word+2][delimiter]..." "[delimiter][delimiter][word+1][delimiter][delimiter][delimiter]..." "...[word-3][delimiter][word-2][delimiter][word-1]" "...[delimiter][word-2][delimiter][word-1][delimiter]" "...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]" </pre> <p><b>Syntax: </b></p> <pre>${WordFind} "[string]" "[delimiter]" "[E][options]" $var </pre> <pre>"[string]" ;[string] ; input string "[delimiter]" ;[delimiter] ; one or several symbols "[E][options]" ;[options] ; +number : word number from start ; -number : word number from end ; +number} : delimiter number from start ; all space after this ; delimiter to output ; +number{ : delimiter number from start ; all space before this ; delimiter to output ; +number}} : word number from start ; all space after this word ; to output ; +number{{ : word number from start ; all space before this word ; to output ; +number{} : word number from start ; all space before and after ; this word (word exclude) ; +number*} : word number from start ; all space after this ; word to output with word ; +number{* : word number from start ; all space before this ; word to output with word ; # : sum of words to output ; * : sum of delimiters to output ; /word : number of word to output ; ;[E] ; with errorlevel output ; IfErrors: ; $var=1 delimiter not found ; $var=2 no such word number ; $var=3 syntax error (Use: +1,-1},#,*,/word,...) ;[] ; no errorlevel output (default) ; If some errors found then (result=input string) ; $var ;output (result) </pre> <p><b>Note:</b> <br>- Accepted numbers 1,01,001,...</p> <p><b>Example (Find word by number):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " C:\" "-02" $R0 	; $R0="Program Files" SectionEnd </pre> <p><b>Example (Delimiter exclude):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "-2}" $R0 	; $R0=" C:\logo.sys C:\WINDOWS" SectionEnd </pre> <p><b>Example (Sum of words):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $R0 	; $R0="3" SectionEnd </pre> <p><b>Example (Sum of delimiters):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0 	; $R0="2" SectionEnd </pre> <p><b>Example (Find word number):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " " "/Files" $R0 	; $R0="3" SectionEnd </pre> <p><b>Example ( }} ):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2}}" $R0 	; $R0=" C:\WINDOWS" SectionEnd </pre> <p><b>Example ( {} ):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2{}" $R0 	; $R0="C:\io.sys C:\WINDOWS" SectionEnd </pre> <p><b>Example ( *} ):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2*}" $R0 	; $R0="C:\logo.sys C:\WINDOWS" SectionEnd </pre> <p><b>Example (Get parent directory):</b></p> <pre>Section 	StrCpy $R0 "C:\Program Files\NSIS\NSIS.chm" ;	 "C:\Program Files\NSIS\Include\" ;	 "C:\\Program Files\\NSIS\\NSIS.chm" 	${WordFind} "$R0" "\" "-2{*" $R0 	; $R0="C:\Program Files\NSIS" 	; "C:\\Program Files\\NSIS" SectionEnd </pre> <p><b>Example (Coordinates):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" ":\lo" "E+1{" $R0 	; $R0="C:\io.sys C" 	IfErrors end 	StrLen $0 $R0 ; $0 = Start position of word (11) 	StrLen $1 ':\lo' ; $1 = Word length (4) 	; StrCpy $R0 $R1 $1 $0 ; $R0 = :\lo 	end: SectionEnd </pre> <p><b>Example (With errorlevel output):</b></p> <pre>Section 	${WordFind} "[string]" "[delimiter]" "E[options]" $R0 	IfErrors 0 end 	StrCmp $R0 1 0 +2 ; errorlevel 1? 	MessageBox MB_OK 'delimiter not found' IDOK end 	StrCmp $R0 2 0 +2 ; errorlevel 2? 	MessageBox MB_OK 'no such word number' IDOK end 	StrCmp $R0 3 0 +2 ; errorlevel 3? 	MessageBox MB_OK 'syntax error' 	end: SectionEnd </pre> <p><b>Example (Without errorlevel output):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys" "_" "+1" $R0 	; $R0="C:\io.sys C:\logo.sys" (error: delimiter "_" not found) SectionEnd </pre> <p><b>Example (If found):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "E+1{" $R0 	IfErrors notfound found 	found: 	MessageBox MB_OK 'Found' IDOK end 	notfound: 	MessageBox MB_OK 'Not found' 	end: SectionEnd </pre> <p><b>Example (If found 2):</b></p> <pre>Section 	${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "+1{" $R0 	StrCmp $R0 "C:\io.sys C:\logo.sys" notfound found ; error? 	found: 	MessageBox MB_OK 'Found' IDOK end 	notfound: 	MessageBox MB_OK 'Not found' 	end: SectionEnd </pre> <p><b>Example (To accept one word in string if delimiter not found):</b></p> <pre>Section 	StrCpy $0 'OneWord' 	StrCpy $1 1 	loop: 	${WordFind} "$0" " " "E+$1" $R0 	IfErrors 0 code 	StrCmp $1$R0 11 0 error 	StrCpy $R0 $0 	goto end 	code: 	; ... 	IntOp $1 $1 + 1 	goto loop 	error: 	StrCpy $1 '' 	StrCpy $R0 '' 	end: 	; $R0="OneWord" SectionEnd </pre> <a name="E.3.3"></a><h3>E.3.3 WordFindS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.2">WordFind</a>, but case sensitive.</li></ul> <a name="E.3.4"></a><h3>E.3.4 WordFind2X</h3> <ul> <li>Find word between two delimiters.</li></ul> <pre>Strings: "[delimiter1][word+1][delimiter2][delimiter1][word+2][delimiter2]..." "[text][delimiter1][text][delimiter1][word+1][delimiter2][text]..." "...[delimiter1][word-2][delimiter2][delimiter1][word-1][delimiter2]" "...[text][delimiter1][text][delimiter1][word-1][delimiter2][text]" </pre> <p><b>Syntax:</b></p> <pre>${WordFind2X} "[string]" "[delimiter1]" "[delimiter2]" "[E][options]" $var </pre> <pre>"[string]" ;[string] ; input string "[delimiter1]" ;[delimiter1] ; first delimiter "[delimiter2]" ;[delimiter2] ; second delimiter "[E][options]" ;[options] ; +number : word number from start ; -number : word number from end ; +number}} : word number from start all space ; after this word to output ; +number{{ : word number from end all space ; before this word to output ; +number{} : word number from start ; all space before and after ; this word (word exclude) ; +number*} : word number from start ; all space after this ; word to output with word ; +number{* : word number from start ; all space before this ; word to output with word ; # : sum of words to output ; /word : number of word to output ; ;[E] ; with errorlevel output ; IfErrors: ; $var=1 no words found ; $var=2 no such word number ; $var=3 syntax error (Use: +1,-1,#) ;[] ; no errorlevel output (default) ; If some errors found then (result=input string) ; $var ;output (result) </pre> <p><b>Example (1):</b></p> <pre>Section 	${WordFind2X} "[C:\io.sys];[C:\logo.sys];[C:\WINDOWS]" "[C:\" "];" "+2" $R0 	; $R0="logo.sys" SectionEnd </pre> <p><b>Example (2):</b></p> <pre>Section 	${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1" $R0 	; $R0="logo" SectionEnd </pre> <p><b>Example (3):</b></p> <pre>Section 	${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{{" $R0 	; $R0="C:\WINDOWS C:\io.sys C:" SectionEnd </pre> <p><b>Example (4):</b></p> <pre>Section 	${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{}" $R0 	; $R0="C:\WINDOWS C:\io.sys C:sys" SectionEnd </pre> <p><b>Example (5):</b></p> <pre>Section 	${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{*" $R0 	; $R0="C:\WINDOWS C:\io.sys C:\logo." SectionEnd </pre> <p><b>Example (6):</b></p> <pre>Section 	${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "/logo" $R0 	; $R0="2" SectionEnd </pre> <p><b>Example (With errorlevel output):</b></p> <pre>Section 	${WordFind2X} "[io.sys];[C:\logo.sys]" "\" "];" "E+1" $R0 	; $R0="1" ("\...];" not found) 	IfErrors 0 noerrors 	MessageBox MB_OK 'Errorlevel=$R0' IDOK end 	noerrors: 	MessageBox MB_OK 'No errors' 	end: SectionEnd </pre> <a name="E.3.5"></a><h3>E.3.5 WordFind2XS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.4">WordFind2X</a>, but case sensitive.</li></ul> <a name="E.3.6"></a><h3>E.3.6 WordFind3X</h3> <ul> <li>Find a word that contains a string, between two delimiters.</li></ul> <p><b>Syntax:</b></p> <pre>${WordFind3X} "[string]" "[delimiter1]" "[center]" "[delimiter2]" "[E][options]" $var </pre> <pre>"[string]" ;[string] ; input string "[delimiter1]" ;[delimiter1] ; first delimiter "[center]" ;[center] ; center string "[delimiter2]" ;[delimiter2] ; second delimiter "[E][options]" ;[options] ; +number : word number from start ; -number : word number from end ; +number}} : word number from start all space ; after this word to output ; +number{{ : word number from end all space ; before this word to output ; +number{} : word number from start ; all space before and after ; this word (word exclude) ; +number*} : word number from start ; all space after this ; word to output with word ; +number{* : word number from start ; all space before this ; word to output with word ; # : sum of words to output ; /word : number of word to output ; ;[E] ; with errorlevel output ; IfErrors: ; $var=1 no words found ; $var=2 no such word number ; $var=3 syntax error (Use: +1,-1,#) ;[] ; no errorlevel output (default) ; If some errors found then (result=input string) ; $var ;output (result) </pre> <p><b>Example (1):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "+1" $R0 	; $R0="1.AAB" SectionEnd </pre> <p><b>Example (2):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1" $R0 	; $R0="2.BAA" SectionEnd </pre> <p><b>Example (3):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{{" $R0 	; $R0="[1.AAB];" SectionEnd </pre> <p><b>Example (4):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{}" $R0 	; $R0="[1.AAB];[3.BBB];" SectionEnd </pre> <p><b>Example (5):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{*" $R0 	; $R0="[1.AAB];[2.BAA];" SectionEnd </pre> <p><b>Example (6):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "/2.BAA" $R0 	; $R0="2" SectionEnd </pre> <p><b>Example (With errorlevel output):</b></p> <pre>Section 	${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "XX" "];" "E+1" $R0 	; $R0="1" ("[...XX...];" not found) 	IfErrors 0 noerrors 	MessageBox MB_OK 'Errorlevel=$R0' IDOK end 	noerrors: 	MessageBox MB_OK 'No errors' 	end: SectionEnd </pre> <a name="E.3.7"></a><h3>E.3.7 WordFind3XS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.6">WordFind3X</a>, but case sensitive.</li></ul> <a name="E.3.8"></a><h3>E.3.8 WordReplace</h3> <ul> <li>Replace or delete word from string.</li></ul> <p><b>Syntax:</b></p> <pre>${WordReplace} "[string]" "[word1]" "[word2]" "[E][options]" $var </pre> <pre>"[string]" ;[string] ; input string "[word1]" ;[word1] ; word to replace or delete "[word2]" ;[word2] ; replace with (if empty delete) "[E][options]" ;[options] ; +number : word number from start ; -number : word number from end ; +number* : word number from start multiple-replace ; -number* : word number from end multiple-replace ; + : replace all results ; +* : multiple-replace all results ; { : if exists replace all delimiters ; from left edge ; } : if exists replace all delimiters ; from right edge ; {} : if exists replace all delimiters ; from edges ; {* : if exists multiple-replace all ; delimiters from left edge ; }* : if exists multiple-replace all ; delimiters from right edge ; {}* : if exists multiple-replace all ; delimiters from edges ; ;[E] ; with errorlevel output ; IfErrors: ; $var=1 word to replace not found ; $var=2 no such word number ; $var=3 syntax error (Use: +1,-1,+1*,-1*,+,+*,{},{}*) ;[] ; no errorlevel output (default) ; If some errors found then (result=input string) ; $var ;output (result) </pre> <p><b>Example (replace):</b></p> <pre>Section 	${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" "SYS" "bmp" "+2" $R0 	; $R0="C:\io.sys C:\logo.bmp C:\WINDOWS" SectionEnd </pre> <p><b>Example (delete):</b></p> <pre>Section 	${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" "SYS" "" "+" $R0 	; $R0="C:\io. C:\logo. C:\WINDOWS" SectionEnd </pre> <p><b>Example (multiple-replace 1):</b></p> <pre>Section 	${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" " " " " "+1*" $R0 	; +1* or +2* or +3* or +4* or +5* or +6* 	; $R0="C:\io.sys C:\logo.sys C:\WINDOWS" SectionEnd </pre> <p><b>Example (multiple-replace 2):</b></p> <pre>Section 	${WordReplace} "C:\io.sys C:\logo.sysSYSsys C:\WINDOWS" "sys" "bmp" "+*" $R0 	; $R0="C:\io.bmp C:\logo.bmp C:\WINDOWS" SectionEnd </pre> <p><b>Example (multiple-replace 3):</b></p> <pre>Section 	${WordReplace} "sysSYSsysC:\io.sys C:\logo.sys C:\WINDOWSsysSYSsys" "sys" "|" "{}*" $R0 	; $R0="|C:\io.sys C:\logo.sys C:\WINDOWS|" SectionEnd </pre> <p><b>Example (With errorlevel output):</b></p> <pre>Section 	${WordReplace} "C:\io.sys C:\logo.sys" "sys" "bmp" "E+3" $R0 	; $R0="2" (no such word number "+3") 	IfErrors 0 noerrors 	MessageBox MB_OK 'Errorlevel=$R0' IDOK end 	noerrors: 	MessageBox MB_OK 'No errors' 	end: SectionEnd </pre> <a name="E.3.9"></a><h3>E.3.9 WordReplaceS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.8">WordReplace</a>, but case sensitive.</li></ul> <a name="E.3.10"></a><h3>E.3.10 WordAdd</h3> <ul> <li>Add words to string1 from string2 if not exist or delete words if exist.</li></ul> <p><b>Syntax:</b></p> <pre>${WordAdd} "[string1]" "[delimiter]" "[E][options]" $var </pre> <pre>"[string1]" ;[string1] ; string for addition or removing "[delimiter]" ;[delimiter] ; one or several symbols "[E][options]" ;[options] ; +string2 : words to add ; -string2 : words to delete ; ;[E] ; with errorlevel output ; IfErrors: ; $var=1 delimiter is empty ; $var=3 syntax error (use: +text,-text) ;[] ; no errorlevel output (default) ; If some errors found then (result=input string) ; $var ;output (result) </pre> <p><b>Example (add):</b></p> <pre>Section 	${WordAdd} "C:\io.sys C:\WINDOWS" " " "+C:\WINDOWS C:\config.sys" $R0 	; $R0="C:\io.sys C:\WINDOWS C:\config.sys" SectionEnd </pre> <p><b>Example (delete):</b></p> <pre>Section 	${WordAdd} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "-C:\WINDOWS C:\config.sys C:\IO.SYS" $R0 	; $R0="C:\logo.sys" SectionEnd </pre> <p><b>Example (add to one):</b></p> <pre>Section 	${WordAdd} "C:\io.sys" " " "+C:\WINDOWS C:\config.sys C:\IO.SYS" $R0 	; $R0="C:\io.sys C:\WINDOWS C:\config.sys" SectionEnd </pre> <p><b>Example (delete one):</b></p> <pre>Section 	${WordAdd} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "-C:\WINDOWS" $R0 	; $R0="C:\io.sys C:\logo.sys" SectionEnd </pre> <p><b>Example (No new words found):</b></p> <pre>Section 	${WordAdd} "C:\io.sys C:\logo.sys" " " "+C:\logo.sys" $R0 	StrCmp $R0 "C:\io.sys C:\logo.sys" 0 +2 	MessageBox MB_OK "No new words found to add" SectionEnd </pre> <p><b>Example (No words deleted):</b></p> <pre>Section 	${WordAdd} "C:\io.sys C:\logo.sys" " " "-C:\config.sys" $R0 	StrCmp $R0 "C:\io.sys C:\logo.sys" 0 +2 	MessageBox MB_OK "No words found to delete" SectionEnd </pre> <p><b>Example (With errorlevel output):</b></p> <pre>Section 	${WordAdd} "C:\io.sys C:\logo.sys" "" "E-C:\logo.sys" $R0 	; $R0="1" (delimiter is empty "") 	IfErrors 0 noerrors 	MessageBox MB_OK 'Errorlevel=$R0' IDOK end 	noerrors: 	MessageBox MB_OK 'No errors' 	end: SectionEnd </pre> <a name="E.3.11"></a><h3>E.3.11 WordAddS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.10">WordAdd</a>, but case sensitive.</li></ul> <a name="E.3.12"></a><h3>E.3.12 WordInsert</h3> <ul> <li>Insert word in string.</li></ul> <p><b>Syntax:</b></p> <pre>${WordInsert} "[string]" "[delimiter]" "[word]" "[E][options]" $var </pre> <pre>"[string]" ;[string] ; input string "[delimiter]" ;[delimiter] ; one or several symbols "[word]" ;[word] ; word to insert "[E][options]" ;[options] ; +number : word number from start ; -number : word number from end ; ;[E] ; with errorlevel output ; IfErrors: ; $var=1 delimiter is empty ; $var=2 wrong word number ; $var=3 syntax error (Use: +1,-1) ;[] ; no errorlevel output (default) ; If some errors found then (result=input string) ; $var ;output (result) </pre> <p><b>Example (1):</b></p> <pre>Section 	${WordInsert} "C:\io.sys C:\WINDOWS" " " "C:\logo.sys" "-2" $R0 	; $R0="C:\io.sys C:\logo.sys C:\WINDOWS" SectionEnd </pre> <p><b>Example (2):</b></p> <pre>Section 	${WordInsert} "C:\io.sys" " " "C:\WINDOWS" "+2" $R0 	; $R0="C:\io.sys C:\WINDOWS" SectionEnd </pre> <p><b>Example (3):</b></p> <pre>Section 	${WordInsert} "" " " "C:\WINDOWS" "+1" $R0 	; $R0="C:\WINDOWS " SectionEnd </pre> <p><b>Example (With errorlevel output):</b></p> <pre>Section 	${WordInsert} "C:\io.sys C:\logo.sys" " " "C:\logo.sys" "E+4" $R0 	; $R0="2" (wrong word number "+4") 	IfErrors 0 noerrors 	MessageBox MB_OK 'Errorlevel=$R0' IDOK end 	noerrors: 	MessageBox MB_OK 'No errors' 	end: SectionEnd </pre> <a name="E.3.13"></a><h3>E.3.13 WordInsertS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.12">WordInsert</a>, but case sensitive.</li></ul> <a name="E.3.14"></a><h3>E.3.14 StrFilter</h3> <ul> <li>Convert string to uppercase or lowercase.</li><li>Set symbol filter.</li></ul> <p><b>Syntax:</b></p> <pre>${StrFilter} "[string]" "[options]" "[symbols1]" "[symbols2]" $var </pre> <pre>"[string]" ;[string] ; input string ; "[options]" ;[+|-][1|2|3|12|23|31][eng|rus] ; + : convert string to uppercase ; - : convert string to lowercase ; 1 : only Digits ; 2 : only Letters ; 3 : only Special ; 12 : only Digits + Letters ; 23 : only Letters + Special ; 31 : only Special + Digits ; eng : English symbols (default) ; rus : Russian symbols ; "[symbols1]" ;[symbols1] ; symbols include (not changeable) ; "[symbols2]" ;[symbols2] ; symbols exclude ; $var ;output (result) </pre> <p><b>Note:</b> <br>- Error flag if syntax error <br>- Same symbol to include & to exclude = to exclude</p> <p><b>Example (UpperCase):</b></p> <pre>Section 	${StrFilter} "123abc 456DEF 7890|%#" "+" "" "" $R0 	; $R0="123ABC 456DEF 7890|%#" SectionEnd </pre> <p><b>Example (LowerCase):</b></p> <pre>Section 	${StrFilter} "123abc 456DEF 7890|%#" "-" "ef" "" $R0 	; $R0="123abc 456dEF 7890|%#" SectionEnd </pre> <p><b>Example (Filter1):</b></p> <pre>Section 	${StrFilter} "123abc 456DEF 7890|%#" "2" "|%" "" $R0 	; $R0="abcDEF|%" ;only Letters + |% SectionEnd </pre> <p><b>Example (Filter2):</b></p> <pre>Section 	${StrFilter} "123abc 456DEF 7890|%#" "13" "af" "4590" $R0 	; $R0="123a 6F 78|%#" ;only Digits + Special + af - 4590 SectionEnd </pre> <p><b>Example (Filter3):</b></p> <pre>Section 	${StrFilter} "123abc 456DEF 7890|%#" "+12" "b" "def" $R0 	; $R0="123AbC4567890" ;only Digits + Letters + b - def SectionEnd </pre> <p><b>Example (Filter4):</b></p> <pre>Section 	${StrFilter} "123abcÀÁÂ 456DEFãäå 7890|%#" "+12rus" "ä" "ãå" $R0 	; $R0="123ÀÁÂ456ä7890" ;only Digits + Letters + ä - ãå SectionEnd </pre> <p><b>Example (English + Russian Letters):</b></p> <pre>Section 	${StrFilter} "123abcÀÁÂ 456DEFãäå 7890|%#" "2rus" "" "" $R0 	; $R0="ÀÁÂãäå" ;only Russian Letters 	${StrFilter} "123abcÀÁÂ 456DEFãäå 7890|%#" "2" "$R0" "" $R0 	; $R0="abcÀÁÂDEFãäå" ;only English + Russian Letters SectionEnd </pre> <p><b>Example (Word Capitalize):</b></p> <pre>Section 	Push "_01-PERPETUOUS_DREAMER__-__THE_SOUND_OF_GOODBYE_(ORIG._MIX).MP3_" 	Call Capitalize 	Pop $R0 	; $R0="_01-Perpetuous_Dreamer__-__The_Sound_Of_Goodbye_(Orig._Mix).mp3_" 	${WordReplace} "$R0" "_" " " "+*" $R0 	; $R0=" 01-Perpetuous Dreamer - The Sound Of Goodbye (Orig. Mix).mp3 " 	${WordReplace} "$R0" " " "" "{}" $R0 	; $R0="01-Perpetuous Dreamer - The Sound Of Goodbye (Orig. Mix).mp3" SectionEnd Function Capitalize 	Exch $R0 	Push $0 	Push $1 	Push $2 	${StrFilter} '$R0' '-eng' '' '' $R0 	${StrFilter} '$R0' '-rus' '' '' $R0 	StrCpy $0 0 	loop: 	IntOp $0 $0 + 1 	StrCpy $1 $R0 1 $0 	StrCmp $1 '' end 	StrCmp $1 ' ' +5 	StrCmp $1 '_' +4 	StrCmp $1 '-' +3 	StrCmp $1 '(' +2 	StrCmp $1 '[' 0 loop 	IntOp $0 $0 + 1 	StrCpy $1 $R0 1 $0 	StrCmp $1 '' end 	${StrFilter} '$1' '+eng' '' '' $1 	${StrFilter} '$1' '+rus' '' '' $1 	StrCpy $2 $R0 $0 	IntOp $0 $0 + 1 	StrCpy $R0 $R0 '' $0 	IntOp $0 $0 - 2 	StrCpy $R0 '$2$1$R0' 	goto loop 	end: 	Pop $2 	Pop $1 	Pop $0 	Exch $R0 FunctionEnd </pre> <a name="E.3.15"></a><h3>E.3.15 StrFilterS</h3> <ul> <li>Same as <a href="AppendixE.html#E.3.14">StrFilter</a>, but case sensitive.</li></ul> <a name="E.3.16"></a><h3>E.3.16 VersionCompare</h3> <ul> <li>Compare version numbers.</li></ul> <p><b>Syntax:</b></p> <pre>${VersionCompare} "[Version1]" "[Version2]" $var </pre> <pre>"[Version1]" ; First version "[Version2]" ; Second version $var ; Result: ; $var=0 Versions are equal ; $var=1 Version1 is newer ; $var=2 Version2 is newer </pre> <p><b>Example:</b></p> <pre>Section 	${VersionCompare} "1.1.1.9" "1.1.1.01" $R0 	; $R0="1" SectionEnd </pre> <a name="E.3.17"></a><h3>E.3.17 VersionConvert</h3> <ul> <li>Convert version in the numerical format which can be compared.</li></ul> <p><b>Syntax:</b></p> <pre>${VersionConvert} "[Version]" "[CharList]" $var </pre> <pre>"[Version]" ; Version ; "[CharList]" ; List of characters, which will be replaced by numbers ; "abcdefghijklmnopqrstuvwxyz" (default) ; $var ; Result: converted version </pre> <p><b>Note:</b> <br>- Converted letters are separated with dot <br>- If character is non-digit and not in list then it will be converted to dot</p> <p><b>Example1:</b></p> <pre>Section 	${VersionConvert} "9.0a" "" $R0 	; $R0="9.0.01" 	${VersionConvert} "9.0c" "" $R1 	; $R1="9.0.03" 	${VersionCompare} "$R0" "$R1" $R2 	; $R2="2" version2 is newer SectionEnd </pre> <p><b>Example2:</b></p> <pre>Section 	${VersionConvert} "0.15c-9m" "" $R0 	; $R0="0.15.03.9.13" 	${VersionConvert} "0.15c-1n" "" $R1 	; $R1="0.15.03.1.14" 	${VersionCompare} "$R0" "$R1" $R2 	; $R2="1" version1 is newer SectionEnd </pre> <p><b>Example3:</b></p> <pre>Section 	${VersionConvert} "0.15c+" "abcdefghijklmnopqrstuvwxyz+" $R0 	; $R0="0.15.0327" 	${VersionConvert} "0.15c" "abcdefghijklmnopqrstuvwxyz+" $R1 	; $R1="0.15.03" 	${VersionCompare} "$R0" "$R1" $R2 	; $R2="1" version1 is newer SectionEnd </pre> <p><a href='AppendixD.html'>Previous</a> | <a href='Contents.html'>Contents</a> | <a href='AppendixF.html'>Next</a></p> <hr /> <address> </address> </body> </html>