| 1 |
\A{headers} Useful Headers |
| 2 |
|
| 3 |
\b \R{tut-logic}{LogicLib} - Evaluate various logic statements with helper macros. |
| 4 |
|
| 5 |
\b Memento.nsh - Remember the users components selection. |
| 6 |
|
| 7 |
\b \R{modernui}{Modern User Interface} - A MSI inspired interface. |
| 8 |
|
| 9 |
\b \L{../Docs/MultiUser/Readme.html}{Multi-User} - Install for a single user or for all users on the computer. |
| 10 |
|
| 11 |
\b Sections.nsh - Manipulate Sections. |
| 12 |
|
| 13 |
\b WinVer.nsh - Detect Windows version. |
| 14 |
|
| 15 |
\b x64.nsh - Detect CPU architecture and bitness. |
| 16 |
|
| 17 |
\H{filefunc} File Functions Header |
| 18 |
|
| 19 |
|
| 20 |
\S1{} Introduction |
| 21 |
|
| 22 |
Include header: |
| 23 |
|
| 24 |
\c !include "FileFunc.nsh" |
| 25 |
|
| 26 |
Call functions: |
| 27 |
|
| 28 |
\c Section Install |
| 29 |
\c ${GetFileExt} "C:\My Downloads\Index.html" $R0 |
| 30 |
\c ; $R0="html" |
| 31 |
\c SectionEnd |
| 32 |
|
| 33 |
\c Section un.Install |
| 34 |
\c ${GetParent} "C:\My Downloads\Index.html" $R0 |
| 35 |
\c ; $R0="C:\My Downloads" |
| 36 |
\c SectionEnd |
| 37 |
|
| 38 |
|
| 39 |
\S1{locate} Locate |
| 40 |
|
| 41 |
\b Find files, directories and empty directories with mask and size options. |
| 42 |
|
| 43 |
\\<b\\>Syntax:\\</b\\> |
| 44 |
|
| 45 |
\c ${Locate} "[Path]" "[Options]" "Function" |
| 46 |
|
| 47 |
\c "[Path]" ; Disk or Directory |
| 48 |
\c ; |
| 49 |
\c "[Options]" ; /L=[FD|F|D|DE|FDE] |
| 50 |
\c ; /L=FD - Locate Files and Directories (default) |
| 51 |
\c ; /L=F - Locate Files only |
| 52 |
\c ; /L=D - Locate Directories only |
| 53 |
\c ; /L=DE - Locate Empty Directories only |
| 54 |
\c ; /L=FDE - Locate Files and Empty Directories |
| 55 |
\c ; /M=[mask] |
| 56 |
\c ; /M=*.* - Locate all (default) |
| 57 |
\c ; /M=*.doc - Locate Work.doc, 1.doc ... |
| 58 |
\c ; /M=Pho* - Locate PHOTOS, phone.txt ... |
| 59 |
\c ; /M=win???.exe - Locate winamp.exe, winver.exe ... |
| 60 |
\c ; /M=winamp.exe - Locate winamp.exe only |
| 61 |
\c ; /S=No:No[B|K|M|G] |
| 62 |
\c ; /S= - Don't locate file size (faster) (default) |
| 63 |
\c ; /S=0:0B - Locate only files of 0 Bytes exactly |
| 64 |
\c ; /S=5:9K - Locate only files of 5 to 9 Kilobytes |
| 65 |
\c ; /S=:10M - Locate only files of 10 Megabyte or less |
| 66 |
\c ; /S=1G - Locate only files of 1 Gigabyte or more |
| 67 |
\c ; /G=[1|0] |
| 68 |
\c ; /G=1 - Locate with subdirectories (default) |
| 69 |
\c ; /G=0 - Locate without subdirectories |
| 70 |
\c ; /B=[0|1] |
| 71 |
\c ; /B=0 - Banner isn't used (default) |
| 72 |
\c ; /B=1 - Banner is used. Callback when function |
| 73 |
\c ; start to search in new directory |
| 74 |
\c "Function" ; Callback function when found |
| 75 |
\c |
| 76 |
\c Function "Function" |
| 77 |
\c ; $R9 "path\name" |
| 78 |
\c ; $R8 "path" |
| 79 |
\c ; $R7 "name" |
| 80 |
\c ; $R6 "size" ($R6="" if directory, $R6="0" if file with /S=) |
| 81 |
\c |
| 82 |
\c ; $R0-$R5 are not used (save data in them). |
| 83 |
\c ; ... |
| 84 |
\c |
| 85 |
\c Push $var ; If $var="StopLocate" Then exit from function |
| 86 |
\c FunctionEnd |
| 87 |
|
| 88 |
\\<b\\>Note:\\</b\\> |
| 89 |
\\<br\\>- Error flag if disk or directory isn't exist |
| 90 |
\\<br\\>- Error flag if syntax error |
| 91 |
\\<br\\>- See also: \W{http://nsis.sf.net/Locate_plugin}{Locate plugin} |
| 92 |
|
| 93 |
|
| 94 |
\\<b\\>Example (Find one file):\\</b\\> |
| 95 |
|
| 96 |
\c Section |
| 97 |
\c ${Locate} "C:\ftp" "/L=F /M=RPC DCOM.rar /S=1K" "Example1" |
| 98 |
\c ; 'RPC DCOM.rar' file in 'C:\ftp' with size 1 Kb or more |
| 99 |
\c |
| 100 |
\c IfErrors 0 +2 |
| 101 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 102 |
\c MessageBox MB_OK "$$R0=$R0" |
| 103 |
\c SectionEnd |
| 104 |
\c |
| 105 |
\c Function Example1 |
| 106 |
\c StrCpy $R0 $R9 |
| 107 |
\c ; $R0="C:\ftp\files\RPC DCOM.rar" |
| 108 |
\c |
| 109 |
\c MessageBox MB_YESNO '$R0$\n$\nFind next?' IDYES +2 |
| 110 |
\c StrCpy $0 StopLocate |
| 111 |
\c |
| 112 |
\c Push $0 |
| 113 |
\c FunctionEnd |
| 114 |
|
| 115 |
\\<b\\>Example (Write results to a text file):\\</b\\> |
| 116 |
|
| 117 |
\c Section |
| 118 |
\c GetTempFileName $R0 |
| 119 |
\c FileOpen $R1 $R0 w |
| 120 |
\c ${Locate} "C:\ftp" "/S=:2M /G=0" "Example2" |
| 121 |
\c ; folders and all files with size 2 Mb or less |
| 122 |
\c ; don't scan subdirectories |
| 123 |
\c FileClose $R1 |
| 124 |
\c |
| 125 |
\c IfErrors 0 +2 |
| 126 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 127 |
\c Exec '"notepad.exe" "$R0"' |
| 128 |
\c SectionEnd |
| 129 |
\c |
| 130 |
\c Function Example2 |
| 131 |
\c StrCmp $R6 '' 0 +3 |
| 132 |
\c FileWrite $R1 "Directory=$R9$\r$\n" |
| 133 |
\c goto +2 |
| 134 |
\c FileWrite $R1 "File=$R9 Size=$R6 Mb$\r$\n" |
| 135 |
\c |
| 136 |
\c Push $0 |
| 137 |
\c FunctionEnd |
| 138 |
|
| 139 |
\\<b\\>Example (Write results to an INI file):\\</b\\> |
| 140 |
|
| 141 |
\c Section |
| 142 |
\c GetTempFileName $R0 |
| 143 |
\c ${Locate} "C:\ftp" "/L=F /S=0K" "Example3" |
| 144 |
\c ; all files in 'C:\ftp' with size detect in Kb |
| 145 |
\c |
| 146 |
\c IfErrors 0 +2 |
| 147 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 148 |
\c Exec '"notepad.exe" "$R0"' |
| 149 |
\c SectionEnd |
| 150 |
\c |
| 151 |
\c Function Example3 |
| 152 |
\c WriteINIStr $R0 "$R8" "$R7" "$R6 Kb" |
| 153 |
\c |
| 154 |
\c Push $0 |
| 155 |
\c FunctionEnd |
| 156 |
|
| 157 |
\\<b\\>Example (Delete empty directories):\\</b\\> |
| 158 |
|
| 159 |
\c Section |
| 160 |
\c StrCpy $R2 0 |
| 161 |
\c StrCpy $R3 0 |
| 162 |
\c |
| 163 |
\c loop: |
| 164 |
\c StrCpy $R1 0 |
| 165 |
\c ${Locate} "C:\ftp" "/L=DE" "Example4" |
| 166 |
\c IntOp $R3 $R3 + 1 |
| 167 |
\c IntOp $R2 $R2 + $R1 |
| 168 |
\c StrCmp $R0 StopLocate +2 |
| 169 |
\c StrCmp $R1 0 0 loop |
| 170 |
\c |
| 171 |
\c IfErrors 0 +2 |
| 172 |
\c MessageBox MB_OK 'error' IDOK +2 |
| 173 |
\c MessageBox MB_OK '$R2 directories were removed$\n$R3 loops' |
| 174 |
\c SectionEnd |
| 175 |
\c |
| 176 |
\c Function Example4 |
| 177 |
\c MessageBox MB_YESNOCANCEL 'Delete empty "$R9"?' IDNO end IDCANCEL cancel |
| 178 |
\c RMDir $R9 |
| 179 |
\c IntOp $R1 $R1 + 1 |
| 180 |
\c goto end |
| 181 |
\c |
| 182 |
\c cancel: |
| 183 |
\c StrCpy $R0 StopLocate |
| 184 |
\c |
| 185 |
\c end: |
| 186 |
\c Push $R0 |
| 187 |
\c FunctionEnd |
| 188 |
|
| 189 |
\\<b\\>Example (Move all files into one folder):\\</b\\> |
| 190 |
|
| 191 |
\c Section |
| 192 |
\c StrCpy $R0 "C:\ftp" ;Directory move from |
| 193 |
\c StrCpy $R1 "C:\ftp2" ;Directory move into |
| 194 |
\c |
| 195 |
\c StrCpy $R2 0 |
| 196 |
\c StrCpy $R3 0 |
| 197 |
\c ${Locate} "$R0" "/L=F" "Example5" |
| 198 |
\c |
| 199 |
\c IfErrors 0 +2 |
| 200 |
\c MessageBox MB_OK 'error' IDOK +4 |
| 201 |
\c StrCmp $R3 0 0 +2 |
| 202 |
\c MessageBox MB_OK '$R2 files were moved' IDOK +2 |
| 203 |
\c MessageBox MB_OK '$R2 files were moved$\n$R3 files were NOT moved' |
| 204 |
\c SectionEnd |
| 205 |
\c |
| 206 |
\c Function Example5 |
| 207 |
\c StrCmp $R8 $R1 +6 |
| 208 |
\c IfFileExists '$R1\$R7' +4 |
| 209 |
\c Rename $R9 '$R1\$R7' |
| 210 |
\c IntOp $R2 $R2 + 1 |
| 211 |
\c goto +2 |
| 212 |
\c IntOp $R3 $R3 + 1 |
| 213 |
\c |
| 214 |
\c Push $0 |
| 215 |
\c FunctionEnd |
| 216 |
|
| 217 |
\\<b\\>Example (Copy files with log):\\</b\\> |
| 218 |
|
| 219 |
\c Section |
| 220 |
\c StrCpy $R0 "C:\ftp" ;Directory copy from |
| 221 |
\c StrCpy $R1 "C:\ftp2" ;Directory copy into |
| 222 |
\c StrLen $R2 $R0 |
| 223 |
\c |
| 224 |
\c GetTempFileName $0 |
| 225 |
\c FileOpen $R3 $0 w |
| 226 |
\c ${Locate} "$R0" "/L=FDE" "Example6" |
| 227 |
\c FileClose $R3 |
| 228 |
\c |
| 229 |
\c IfErrors 0 +2 |
| 230 |
\c MessageBox MB_OK 'error' |
| 231 |
\c |
| 232 |
\c Exec '"notepad.exe" "$0"' ;view log |
| 233 |
\c SectionEnd |
| 234 |
\c |
| 235 |
\c Function Example6 |
| 236 |
\c StrCpy $1 $R8 '' $R2 |
| 237 |
\c |
| 238 |
\c StrCmp $R6 '' 0 +3 |
| 239 |
\c CreateDirectory '$R1$1\$R7' |
| 240 |
\c goto end |
| 241 |
\c CreateDirectory '$R1$1' |
| 242 |
\c CopyFiles /SILENT $R9 '$R1$1' |
| 243 |
\c |
| 244 |
\c IfFileExists '$R1$1\$R7' 0 +3 |
| 245 |
\c FileWrite $R3 "-old:$R9 -new:$R1$1\$R7 -success$\r$\n" |
| 246 |
\c goto +2 |
| 247 |
\c FileWrite $R3 "-old:$R9 -new:$R1$1\$R7 -failed$\r$\n" |
| 248 |
\c |
| 249 |
\c end: |
| 250 |
\c Push $0 |
| 251 |
\c FunctionEnd |
| 252 |
|
| 253 |
\\<b\\>Example (Recreate directory structure):\\</b\\> |
| 254 |
|
| 255 |
\c Section |
| 256 |
\c StrCpy $R0 "C:\ftp" ;Directory structure from |
| 257 |
\c StrCpy $R1 "C:\ftp2" ;Directory structure into |
| 258 |
\c StrLen $R2 $R0 |
| 259 |
\c |
| 260 |
\c ${Locate} "$R0" "/L=D" "Example7" |
| 261 |
\c |
| 262 |
\c IfErrors 0 +2 |
| 263 |
\c MessageBox MB_OK 'error' |
| 264 |
\c SectionEnd |
| 265 |
\c |
| 266 |
\c Function Example7 |
| 267 |
\c StrCpy $1 $R9 '' $R2 |
| 268 |
\c CreateDirectory '$R1$1' |
| 269 |
\c |
| 270 |
\c Push $0 |
| 271 |
\c FunctionEnd |
| 272 |
|
| 273 |
\\<b\\>Example (Locate with banner - \W{https://nsis.sourceforge.io/Nxs_plug-in}{NxS plugin} required):\\</b\\> |
| 274 |
|
| 275 |
\c Section |
| 276 |
\c nxs::Show /NOUNLOAD `$(^Name) Setup` /top \ |
| 277 |
\c `Setup searching something$\r$\nPlease wait... If you can..` \ |
| 278 |
\c /h 1 /can 1 /end |
| 279 |
\c ${Locate} "C:\WINDOWS" "/L=F /M=*.inf /B=1" "Example8" |
| 280 |
\c nxs::Destroy |
| 281 |
\c SectionEnd |
| 282 |
\c |
| 283 |
\c Function Example8 |
| 284 |
\c StrCmp $R0 $R8 abortcheck |
| 285 |
\c StrCpy $R0 $R8 |
| 286 |
\c nxs::Update /NOUNLOAD /sub "$R8" /pos 78 /end |
| 287 |
\c |
| 288 |
\c abortcheck: |
| 289 |
\c nxs::HasUserAborted /NOUNLOAD |
| 290 |
\c Pop $0 |
| 291 |
\c StrCmp $0 1 0 +2 |
| 292 |
\c StrCpy $0 StopLocate |
| 293 |
\c |
| 294 |
\c StrCmp $R9 '' end |
| 295 |
\c ;... |
| 296 |
\c |
| 297 |
\c end: |
| 298 |
\c Push $0 |
| 299 |
\c FunctionEnd |
| 300 |
|
| 301 |
\S1{getsize} GetSize |
| 302 |
|
| 303 |
\b Find the size of a file, files mask or directory. |
| 304 |
|
| 305 |
\b Find the sum of the files, directories and subdirectories. |
| 306 |
|
| 307 |
\\<b\\>Syntax:\\</b\\> |
| 308 |
|
| 309 |
\c ${GetSize} "[Path]" "[Options]" $var1 $var2 $var3 |
| 310 |
|
| 311 |
\c "[Path]" ; Disk or Directory |
| 312 |
\c ; |
| 313 |
\c "[Options]" ; /M=[mask] |
| 314 |
\c ; /M=*.* - Find all (default) |
| 315 |
\c ; /M=*.doc - Find Work.doc, 1.doc ... |
| 316 |
\c ; /M=Pho* - Find PHOTOS, phone.txt ... |
| 317 |
\c ; /M=win???.exe - Find winamp.exe, winver.exe ... |
| 318 |
\c ; /M=winamp.exe - Find winamp.exe only |
| 319 |
\c ; /S=No:No[B|K|M|G] |
| 320 |
\c ; /S= - Don't find file size (faster) (default) |
| 321 |
\c ; /S=0:0B - Find only files of 0 Bytes exactly |
| 322 |
\c ; /S=5:9K - Find only files of 5 to 9 Kilobytes |
| 323 |
\c ; /S=:10M - Find only files of 10 Megabyte or less |
| 324 |
\c ; /S=1G - Find only files of 1 Gigabyte or more |
| 325 |
\c ; /G=[1|0] |
| 326 |
\c ; /G=1 - Find with subdirectories (default) |
| 327 |
\c ; /G=0 - Find without subdirectories |
| 328 |
\c ; |
| 329 |
\c $var1 ; Result1: Size |
| 330 |
\c $var2 ; Result2: Sum of files |
| 331 |
\c $var3 ; Result3: Sum of directories |
| 332 |
|
| 333 |
\\<b\\>Note:\\</b\\> |
| 334 |
\\<br\\>- Error flag if disk or directory isn't exist |
| 335 |
\\<br\\>- Error flag if syntax error |
| 336 |
\\<br\\>- See also: \W{http://nsis.sf.net/Locate_plugin}{Locate plugin} |
| 337 |
|
| 338 |
|
| 339 |
\\<b\\>Examples:\\</b\\> |
| 340 |
|
| 341 |
\c Section 'Find file size of "$WINDIR\Explorer.exe" in KiB' |
| 342 |
\c |
| 343 |
\c ${GetSize} "$WINDIR" "/M=Explorer.exe /S=0K /G=0" $0 $1 $2 |
| 344 |
\c ; $0="220" KiB |
| 345 |
\c ; $1="1" files |
| 346 |
\c ; $2="" directories |
| 347 |
\c |
| 348 |
\c IfErrors 0 +2 |
| 349 |
\c MessageBox MB_OK "Error" |
| 350 |
\c SectionEnd |
| 351 |
|
| 352 |
\c Section 'Find folder size of "C:\Installs\Drivers" in MiB' |
| 353 |
\c |
| 354 |
\c ${GetSize} "C:\Installs\Drivers" "/S=0M" $0 $1 $2 |
| 355 |
\c ; $0="132" MiB |
| 356 |
\c ; $1="555" files |
| 357 |
\c ; $2="55" directories |
| 358 |
\c |
| 359 |
\c IfErrors 0 +2 |
| 360 |
\c MessageBox MB_OK "Error" |
| 361 |
\c SectionEnd |
| 362 |
|
| 363 |
\c Section 'Find sum of files and folders in "$WINDIR" (no subfolders)' |
| 364 |
\c |
| 365 |
\c ${GetSize} "$WINDIR" "/G=0" $0 $1 $2 |
| 366 |
\c ; $0="" size |
| 367 |
\c ; $1="253" files |
| 368 |
\c ; $2="46" directories |
| 369 |
\c |
| 370 |
\c IfErrors 0 +2 |
| 371 |
\c MessageBox MB_OK "Error" |
| 372 |
\c SectionEnd |
| 373 |
|
| 374 |
\S1{drivespace} DriveSpace |
| 375 |
|
| 376 |
\b Get total, occupied or free space of the drive. |
| 377 |
|
| 378 |
\\<b\\>Syntax:\\</b\\> |
| 379 |
|
| 380 |
\c ${DriveSpace} "[Drive]" "[Options]" $var |
| 381 |
|
| 382 |
\c "[Drive]" ; Disk to check |
| 383 |
\c ; |
| 384 |
\c "[Options]" ; /D=[T|O|F] |
| 385 |
\c ; /D=T - Total space (default) |
| 386 |
\c ; /D=O - Occupied space |
| 387 |
\c ; /D=F - Free space |
| 388 |
\c ; /S=[B|K|M|G] |
| 389 |
\c ; /S=B - size in Bytes (default) |
| 390 |
\c ; /S=K - size in Kilobytes |
| 391 |
\c ; /S=M - size in Megabytes |
| 392 |
\c ; /S=G - size in Gigabytes |
| 393 |
\c ; |
| 394 |
\c $var ; Result: Size |
| 395 |
|
| 396 |
\\<b\\>Note:\\</b\\> |
| 397 |
\\<br\\>- Error flag if disk isn't exist or not ready |
| 398 |
\\<br\\>- Error flag if syntax error |
| 399 |
|
| 400 |
|
| 401 |
\\<b\\>Example:\\</b\\> |
| 402 |
|
| 403 |
\c Section |
| 404 |
\c ${DriveSpace} "C:\" "/D=F /S=M" $R0 |
| 405 |
\c ; $R0="2530" megabytes free on drive C: |
| 406 |
\c SectionEnd |
| 407 |
|
| 408 |
\S1{getdrives} GetDrives |
| 409 |
|
| 410 |
\b Find all available drives in the system. |
| 411 |
|
| 412 |
\\<b\\>Syntax:\\</b\\> |
| 413 |
|
| 414 |
\c ${GetDrives} "[Option]" "Function" |
| 415 |
|
| 416 |
\c "[Option]" ; [FDD+HDD+CDROM+NET+RAM] |
| 417 |
\c ; FDD Floppy Disk Drives |
| 418 |
\c ; HDD Hard Disk Drives |
| 419 |
\c ; CDROM CD-ROM Drives |
| 420 |
\c ; NET Network Drives |
| 421 |
\c ; RAM RAM Disk Drives |
| 422 |
\c ; |
| 423 |
\c ; [ALL] |
| 424 |
\c ; Find all drives by letter (default) |
| 425 |
\c ; |
| 426 |
\c "Function" ; Callback function when found |
| 427 |
\c |
| 428 |
\c Function "Function" |
| 429 |
\c ; $9 "drive letter" (a:\ c:\ ...) |
| 430 |
\c ; $8 "drive type" (FDD HDD ...) |
| 431 |
\c |
| 432 |
\c ; $R0-$R9 are not used (save data in them). |
| 433 |
\c ; ... |
| 434 |
\c |
| 435 |
\c Push $var ; If $var="StopGetDrives" Then exit from function |
| 436 |
\c FunctionEnd |
| 437 |
|
| 438 |
\\<b\\>Example1:\\</b\\> |
| 439 |
|
| 440 |
\c Section |
| 441 |
\c ${GetDrives} "FDD+CDROM" "Example1" |
| 442 |
\c SectionEnd |
| 443 |
\c |
| 444 |
\c Function Example1 |
| 445 |
\c MessageBox MB_OK "$9 ($8 Drive)" |
| 446 |
\c |
| 447 |
\c Push $0 |
| 448 |
\c FunctionEnd |
| 449 |
|
| 450 |
\\<b\\>Example2:\\</b\\> |
| 451 |
|
| 452 |
\c Section |
| 453 |
\c ${GetDrives} "ALL" "Example2" |
| 454 |
\c SectionEnd |
| 455 |
\c |
| 456 |
\c Function Example2 |
| 457 |
\c MessageBox MB_OK "$9 ($8 Drive)" |
| 458 |
\c |
| 459 |
\c Push $0 |
| 460 |
\c FunctionEnd |
| 461 |
|
| 462 |
\\<b\\>Example3 (Get type of drive):\\</b\\> |
| 463 |
|
| 464 |
\c Section |
| 465 |
\c StrCpy $R0 "D:\" ;Drive letter |
| 466 |
\c StrCpy $R1 "invalid" |
| 467 |
\c |
| 468 |
\c ${GetDrives} "ALL" "Example3" |
| 469 |
\c |
| 470 |
\c MessageBox MB_OK "Type of drive $R0 is $R1" |
| 471 |
\c SectionEnd |
| 472 |
\c |
| 473 |
\c Function Example3 |
| 474 |
\c StrCmp $9 $R0 0 +3 |
| 475 |
\c StrCpy $R1 $8 |
| 476 |
\c StrCpy $0 StopGetDrives |
| 477 |
\c |
| 478 |
\c Push $0 |
| 479 |
\c FunctionEnd |
| 480 |
|
| 481 |
\S1{gettime} GetTime |
| 482 |
|
| 483 |
\b Get local or system time. |
| 484 |
|
| 485 |
\b Get file time (access, creation and modification). |
| 486 |
|
| 487 |
\\<b\\>Syntax:\\</b\\> |
| 488 |
|
| 489 |
\c ${GetTime} "[File]" "[Option]" $var1 $var2 $var3 $var4 $var5 $var6 $var7 |
| 490 |
|
| 491 |
\c "[File]" ; Ignored if "L" or "LS" |
| 492 |
\c ; |
| 493 |
\c "[Option]" ; [Options] |
| 494 |
\c ; L Local time |
| 495 |
\c ; A last Access file time |
| 496 |
\c ; C Creation file time |
| 497 |
\c ; M Modification file time |
| 498 |
\c ; LS System time (UTC) |
| 499 |
\c ; AS last Access file time (UTC) |
| 500 |
\c ; CS Creation file time (UTC) |
| 501 |
\c ; MS Modification file time (UTC) |
| 502 |
\c ; |
| 503 |
\c $var1 ; Result1: day |
| 504 |
\c $var2 ; Result2: month |
| 505 |
\c $var3 ; Result3: year |
| 506 |
\c $var4 ; Result4: day of week name |
| 507 |
\c $var5 ; Result5: hour |
| 508 |
\c $var6 ; Result6: minute |
| 509 |
\c $var7 ; Result7: seconds |
| 510 |
|
| 511 |
\\<b\\>Note:\\</b\\> |
| 512 |
\\<br\\>- Error flag if file isn't exist |
| 513 |
\\<br\\>- Error flag if syntax error |
| 514 |
\\<br\\>- See also: \W{http://nsis.sf.net/Time_plugin}{Time plugin} |
| 515 |
|
| 516 |
|
| 517 |
\\<b\\>Examples:\\</b\\> |
| 518 |
|
| 519 |
\c Section 'Get local time' |
| 520 |
\c ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 |
| 521 |
\c ; $0="01" day |
| 522 |
\c ; $1="04" month |
| 523 |
\c ; $2="2005" year |
| 524 |
\c ; $3="Friday" day of week name |
| 525 |
\c ; $4="16" hour |
| 526 |
\c ; $5="05" minute |
| 527 |
\c ; $6="50" seconds |
| 528 |
\c |
| 529 |
\c MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' |
| 530 |
\c SectionEnd |
| 531 |
|
| 532 |
\c Section 'Get file time' |
| 533 |
\c ${GetTime} "$WINDIR\Explorer.exe" "C" $0 $1 $2 $3 $4 $5 $6 |
| 534 |
\c ; $0="12" day |
| 535 |
\c ; $1="10" month |
| 536 |
\c ; $2="2004" year |
| 537 |
\c ; $3="Tuesday" day of week name |
| 538 |
\c ; $4="2" hour |
| 539 |
\c ; $5="32" minute |
| 540 |
\c ; $6="03" seconds |
| 541 |
\c |
| 542 |
\c IfErrors 0 +2 |
| 543 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 544 |
\c MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' |
| 545 |
\c SectionEnd |
| 546 |
|
| 547 |
\c Section 'Get system time' |
| 548 |
\c ${GetTime} "" "LS" $0 $1 $2 $3 $4 $5 $6 |
| 549 |
\c ; $0="01" day |
| 550 |
\c ; $1="04" month |
| 551 |
\c ; $2="2005" year |
| 552 |
\c ; $3="Friday" day of week name |
| 553 |
\c ; $4="11" hour |
| 554 |
\c ; $5="05" minute |
| 555 |
\c ; $6="50" seconds |
| 556 |
\c |
| 557 |
\c MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6' |
| 558 |
\c SectionEnd |
| 559 |
|
| 560 |
\c Section 'Convert time to 12-hour format AM/PM' |
| 561 |
\c ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 |
| 562 |
\c |
| 563 |
\c StrCmp $4 0 0 +3 |
| 564 |
\c StrCpy $4 12 |
| 565 |
\c goto +3 |
| 566 |
\c StrCmp $4 12 +5 |
| 567 |
\c IntCmp $4 12 0 0 +3 |
| 568 |
\c StrCpy $7 AM |
| 569 |
\c goto +3 |
| 570 |
\c IntOp $4 $4 - 12 |
| 571 |
\c StrCpy $7 PM |
| 572 |
\c |
| 573 |
\c MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6 $7' |
| 574 |
\c SectionEnd |
| 575 |
|
| 576 |
\S1{getfileattributes} GetFileAttributes |
| 577 |
|
| 578 |
\b Get attributes of file or directory. |
| 579 |
|
| 580 |
\\<b\\>Syntax:\\</b\\> |
| 581 |
|
| 582 |
\c ${GetFileAttributes} "[File]" "[Attributes]" $var |
| 583 |
|
| 584 |
\c "[File]" ; File or directory |
| 585 |
\c ; |
| 586 |
\c "[Attributes]" ; "ALL" (default) |
| 587 |
\c ; -all attributes of file combined with "|" to output |
| 588 |
\c ; |
| 589 |
\c ; "READONLY|HIDDEN|SYSTEM|DIRECTORY|ARCHIVE| |
| 590 |
\c ; DEVICE|NORMAL|TEMPORARY|SPARSE_FILE|REPARSE_POINT| |
| 591 |
\c ; COMPRESSED|OFFLINE|NOT_CONTENT_INDEXED|ENCRYPTED" |
| 592 |
\c ; -file must have specified attributes |
| 593 |
\c ; |
| 594 |
\c $var ; Result: |
| 595 |
\c ; $var=attr1|attr2|... (if used "ALL") |
| 596 |
\c ; $var=1 file has specified attributes |
| 597 |
\c ; $var=0 file has no specified attributes |
| 598 |
|
| 599 |
\\<b\\>Note:\\</b\\> |
| 600 |
\\<br\\>- Error flag is set if file doesn't exist |
| 601 |
|
| 602 |
|
| 603 |
\\<b\\>Example:\\</b\\> |
| 604 |
|
| 605 |
\c Section |
| 606 |
\c ${GetFileAttributes} "C:\MSDOS.SYS" "ALL" $R0 |
| 607 |
\c ; $R0=READONLY|HIDDEN|SYSTEM|ARCHIVE |
| 608 |
\c |
| 609 |
\c ${GetFileAttributes} "C:\MSDOS.SYS" "SYSTEM|HIDDEN" $R0 |
| 610 |
\c ; $R0=1 |
| 611 |
\c |
| 612 |
\c ${GetFileAttributes} "C:\MSDOS.SYS" "NORMAL" $R0 |
| 613 |
\c ; $R0=0 |
| 614 |
\c SectionEnd |
| 615 |
|
| 616 |
\S1{getfileversion} GetFileVersion |
| 617 |
|
| 618 |
\b Get version information from executable file. |
| 619 |
|
| 620 |
\\<b\\>Syntax:\\</b\\> |
| 621 |
|
| 622 |
\c ${GetFileVersion} "[Executable]" $var |
| 623 |
|
| 624 |
\c "[Executable]" ; Executable file (*.exe *.dll ...) |
| 625 |
\c $var ; Result: Version number |
| 626 |
|
| 627 |
\\<b\\>Note:\\</b\\> |
| 628 |
\\<br\\>- Error flag if file doesn't exist |
| 629 |
\\<br\\>- Error flag if file doesn't contain version information |
| 630 |
|
| 631 |
|
| 632 |
\\<b\\>Example:\\</b\\> |
| 633 |
|
| 634 |
\c ${GetFileVersion} "C:\ftp\program.exe" $R0 ; $R0="1.1.0.12" |
| 635 |
|
| 636 |
\S1{getexename} GetExeName |
| 637 |
|
| 638 |
\b Get installer filename (with valid case for Windows 98/Me). |
| 639 |
|
| 640 |
\\<b\\>Syntax:\\</b\\> |
| 641 |
|
| 642 |
\c ${GetExeName} $var |
| 643 |
|
| 644 |
\\<b\\>Example:\\</b\\> |
| 645 |
|
| 646 |
\c ${GetExeName} $R0 ; $R0="C:\ftp\program.exe" |
| 647 |
|
| 648 |
\S1{getexepath} GetExePath |
| 649 |
|
| 650 |
\b Get installer pathname ($EXEDIR with valid case for Windows 98/Me). |
| 651 |
|
| 652 |
\\<b\\>Syntax:\\</b\\> |
| 653 |
|
| 654 |
\c ${GetExePath} $var |
| 655 |
|
| 656 |
\\<b\\>Example:\\</b\\> |
| 657 |
|
| 658 |
\c ${GetExePath} $R0 ; $R0="C:\ftp" |
| 659 |
|
| 660 |
\S1{getparameters} GetParameters |
| 661 |
|
| 662 |
\b Get command line parameters. |
| 663 |
|
| 664 |
\\<b\\>Syntax:\\</b\\> |
| 665 |
|
| 666 |
\c ${GetParameters} $var |
| 667 |
|
| 668 |
\\<b\\>Example:\\</b\\> |
| 669 |
|
| 670 |
\c ${GetParameters} $R0 ; $R0="[parameters]" |
| 671 |
|
| 672 |
\S1{getoptions} GetOptions |
| 673 |
|
| 674 |
\b Get options from command line parameters. |
| 675 |
|
| 676 |
\\<b\\>Syntax:\\</b\\> |
| 677 |
|
| 678 |
\c ${GetOptions} "[Parameters]" "[Option]" $var |
| 679 |
|
| 680 |
\c "[Parameters]" ; command line parameters |
| 681 |
\c ; |
| 682 |
\c "[Option]" ; option name |
| 683 |
\c ; |
| 684 |
\c $var ; Result: option string |
| 685 |
|
| 686 |
\\<b\\>Note:\\</b\\> |
| 687 |
\\<br\\>- The error flag is set if the option is not found |
| 688 |
\\<br\\>- The first character in the option string is treated as a parameter delimiter |
| 689 |
|
| 690 |
|
| 691 |
\\<b\\>Example1:\\</b\\> |
| 692 |
|
| 693 |
\c Section |
| 694 |
\c ${GetOptions} "/S /T" "/T" $R0 |
| 695 |
\c |
| 696 |
\c IfErrors 0 +2 |
| 697 |
\c MessageBox MB_OK "Not found" IDOK +2 |
| 698 |
\c MessageBox MB_OK "Found" |
| 699 |
\c SectionEnd |
| 700 |
|
| 701 |
\\<b\\>Example2:\\</b\\> |
| 702 |
|
| 703 |
\c Section |
| 704 |
\c ${GetOptions} "-INSTDIR=C:\Program Files\Common Files -SILENT=yes" "-INSTDIR=" $R0 |
| 705 |
\c ;$R0=C:\Program Files\Common Files |
| 706 |
\c SectionEnd |
| 707 |
|
| 708 |
\\<b\\>Example3:\\</b\\> |
| 709 |
|
| 710 |
\c Section |
| 711 |
\c ${GetOptions} '/SILENT=yes /INSTDIR="C:/Program Files/Common Files" /ADMIN=password' "/INSTDIR=" $R0 |
| 712 |
\c ;$R0=C:/Program Files/Common Files |
| 713 |
\c SectionEnd |
| 714 |
|
| 715 |
\\<b\\>Example4:\\</b\\> |
| 716 |
|
| 717 |
\c Section |
| 718 |
\c ${GetOptions} `-SILENT=yes -INSTDIR='"C:/Program Files/Common Files"' -ADMIN=password` "-INSTDIR=" $R0 |
| 719 |
\c ;$R0="C:/Program Files/Common Files" |
| 720 |
\c SectionEnd |
| 721 |
|
| 722 |
\S1{getoptionss} GetOptionsS |
| 723 |
|
| 724 |
\b Same as \R{getoptions}{GetOptions}, but case sensitive. |
| 725 |
|
| 726 |
\S1{getroot} GetRoot |
| 727 |
|
| 728 |
\b Get root directory. |
| 729 |
|
| 730 |
\\<b\\>Syntax:\\</b\\> |
| 731 |
|
| 732 |
\c ${GetRoot} "[FullPath]" $var |
| 733 |
|
| 734 |
\\<b\\>Examples:\\</b\\> |
| 735 |
|
| 736 |
\c ${GetRoot} "C:\Program Files\NSIS" $R0 ; $R0="C:" |
| 737 |
\c ${GetRoot} "\\SuperPimp\NSIS\Source\exehead\Ui.c" $R0 ; $R0="\\SuperPimp\NSIS" |
| 738 |
|
| 739 |
\S1{getparent} GetParent |
| 740 |
|
| 741 |
\b Get parent directory. |
| 742 |
|
| 743 |
\\<b\\>Syntax:\\</b\\> |
| 744 |
|
| 745 |
\c ${GetParent} "[PathString]" $var |
| 746 |
|
| 747 |
\\<b\\>Example:\\</b\\> |
| 748 |
|
| 749 |
\c ${GetParent} "C:\Program Files\Winamp\uninstwa.exe" $R0 ; $R0="C:\Program Files\Winamp" |
| 750 |
|
| 751 |
\S1{getfilename} GetFileName |
| 752 |
|
| 753 |
\b Get last part from directory path. |
| 754 |
|
| 755 |
\\<b\\>Syntax:\\</b\\> |
| 756 |
|
| 757 |
\c ${GetFileName} "[PathString]" $var |
| 758 |
|
| 759 |
\\<b\\>Example:\\</b\\> |
| 760 |
|
| 761 |
\c ${GetFileName} "C:\Program Files\Winamp\uninstwa.exe" $R0 ; $R0="uninstwa.exe" |
| 762 |
|
| 763 |
\S1{getbasename} GetBaseName |
| 764 |
|
| 765 |
\b Get file name without extension. |
| 766 |
|
| 767 |
\\<b\\>Syntax:\\</b\\> |
| 768 |
|
| 769 |
\c ${GetBaseName} "[FileString]" $var |
| 770 |
|
| 771 |
\\<b\\>Example:\\</b\\> |
| 772 |
|
| 773 |
\c ${GetBaseName} "C:\ftp\program.exe" $R0 ; $R0="program" |
| 774 |
|
| 775 |
\S1{getfileext} GetFileExt |
| 776 |
|
| 777 |
\b Get extension of file. |
| 778 |
|
| 779 |
\\<b\\>Syntax:\\</b\\> |
| 780 |
|
| 781 |
\c ${GetFileExt} "[FileString]" $var |
| 782 |
|
| 783 |
\\<b\\>Example:\\</b\\> |
| 784 |
|
| 785 |
\c ${GetFileExt} "C:\ftp\program.exe" $R0 ; $R0="exe" |
| 786 |
|
| 787 |
\S1{bannertrimpath} BannerTrimPath |
| 788 |
|
| 789 |
\b Trim string path for banner. |
| 790 |
|
| 791 |
\\<b\\>Syntax:\\</b\\> |
| 792 |
|
| 793 |
\c ${BannerTrimPath} "[PathString]" "[Option]" $var |
| 794 |
|
| 795 |
\c "[PathString]" ; |
| 796 |
\c ; |
| 797 |
\c "[Option]" ; [Length][A|B|C|D] |
| 798 |
\c ; |
| 799 |
\c ; Length -Maximum string length |
| 800 |
\c ; A -Trim center path (default) |
| 801 |
\c ; (C:\root\...\third path) |
| 802 |
\c ; If A mode not possible Then will be used B mode |
| 803 |
\c ; B -Trim right path |
| 804 |
\c ; (C:\root\second path\...) |
| 805 |
\c ; If B mode not possible Then will be used C mode |
| 806 |
\c ; C -Trim right string |
| 807 |
\c ; (C:\root\second path\third p...) |
| 808 |
\c ; D -Trim right string + filename |
| 809 |
\c ; (C:\root\second p...\third path) |
| 810 |
\c ; If D mode not possible Then will be used C mode |
| 811 |
\c ; |
| 812 |
\c $var ; Result: Trimmed path |
| 813 |
|
| 814 |
\\<b\\>Example:\\</b\\> |
| 815 |
|
| 816 |
\c Section |
| 817 |
\c ${BannerTrimPath} "C:\Server\Documents\Terminal\license.htm" "35A" $R0 |
| 818 |
\c ;$R0=C:\Server\...\Terminal\license.htm |
| 819 |
\c SectionEnd |
| 820 |
|
| 821 |
\\<b\\>Example (Banner plugin):\\</b\\> |
| 822 |
|
| 823 |
\c !include "WinMessages.nsh" |
| 824 |
\c !include "FileFunc.nsh" |
| 825 |
\c |
| 826 |
\c Section |
| 827 |
\c Banner::show "Starting..." |
| 828 |
\c Banner::getWindow |
| 829 |
\c Pop $R1 |
| 830 |
\c ${Locate} "$WINDIR" "/L=F /M=*.* /B=1" "LocateCallback" |
| 831 |
\c Banner::destroy |
| 832 |
\c SectionEnd |
| 833 |
\c |
| 834 |
\c Function LocateCallback |
| 835 |
\c StrCmp $R0 $R8 code |
| 836 |
\c StrCpy $R0 $R8 |
| 837 |
\c ${BannerTrimPath} "$R8" "38B" $R8 |
| 838 |
\c GetDlgItem $1 $R1 1030 |
| 839 |
\c SendMessage $1 ${WM_SETTEXT} 0 "STR:$R8" |
| 840 |
\c |
| 841 |
\c code: |
| 842 |
\c StrCmp $R9 '' end |
| 843 |
\c ;... |
| 844 |
\c |
| 845 |
\c end: |
| 846 |
\c Push $0 |
| 847 |
\c FunctionEnd |
| 848 |
|
| 849 |
\\<b\\>Example (\W{https://nsis.sourceforge.io/Nxs_plug-in}{NxS plugin}):\\</b\\> |
| 850 |
|
| 851 |
\c !include "FileFunc.nsh" |
| 852 |
\c |
| 853 |
\c Section |
| 854 |
\c nxs::Show /NOUNLOAD `$(^Name) Setup`\ |
| 855 |
\c /top `Setup searching something$\nPlease wait$\nIf you can...`\ |
| 856 |
\c /h 1 /can 1 /end |
| 857 |
\c ${Locate} "$WINDIR" "/L=F /M=*.* /B=1" "LocateCallback" |
| 858 |
\c nxs::Destroy |
| 859 |
\c SectionEnd |
| 860 |
\c |
| 861 |
\c Function LocateCallback |
| 862 |
\c StrCmp $R0 $R8 abortcheck |
| 863 |
\c StrCpy $R0 $R8 |
| 864 |
\c ${BannerTrimPath} "$R8" "55A" $R8 |
| 865 |
\c nxs::Update /NOUNLOAD /sub "$R8" /pos 78 /end |
| 866 |
\c |
| 867 |
\c abortcheck: |
| 868 |
\c nxs::HasUserAborted /NOUNLOAD |
| 869 |
\c Pop $0 |
| 870 |
\c StrCmp $0 1 0 +2 |
| 871 |
\c StrCpy $0 StopLocate |
| 872 |
\c |
| 873 |
\c StrCmp $R9 '' end |
| 874 |
\c ;... |
| 875 |
\c |
| 876 |
\c end: |
| 877 |
\c Push $0 |
| 878 |
\c FunctionEnd |
| 879 |
|
| 880 |
\S1{dirstate} DirState |
| 881 |
|
| 882 |
\b Check directory full, empty or not exist. |
| 883 |
|
| 884 |
\\<b\\>Syntax:\\</b\\> |
| 885 |
|
| 886 |
\c ${DirState} "[path]" $var |
| 887 |
|
| 888 |
\c "[path]" ; Directory |
| 889 |
\c $var ; Result: |
| 890 |
\c ; $var=0 (empty) |
| 891 |
\c ; $var=1 (full) |
| 892 |
\c ; $var=-1 (directory not found) |
| 893 |
|
| 894 |
\\<b\\>Example:\\</b\\> |
| 895 |
|
| 896 |
\c ${DirState} "$TEMP" $R0 ; $R0="1" (directory is full) |
| 897 |
|
| 898 |
\S1{refreshshellicons} RefreshShellIcons |
| 899 |
|
| 900 |
\b After changing file associations, you can call this function to refresh the shell immediately. |
| 901 |
|
| 902 |
\\<b\\>Syntax:\\</b\\> |
| 903 |
|
| 904 |
\c ${RefreshShellIcons} |
| 905 |
|
| 906 |
\\<b\\>Example:\\</b\\> |
| 907 |
|
| 908 |
\c Section |
| 909 |
\c WriteRegStr HKCR "Winamp.File\DefaultIcon" "" "$INSTDIR\WINAMP.EXE,2" |
| 910 |
\c ${RefreshShellIcons} |
| 911 |
\c SectionEnd |
| 912 |
|
| 913 |
|
| 914 |
\H{textfunc} Text Functions Header |
| 915 |
|
| 916 |
|
| 917 |
\S1{} Introduction |
| 918 |
|
| 919 |
Include header: |
| 920 |
|
| 921 |
\c !include "TextFunc.nsh" |
| 922 |
|
| 923 |
Call functions: |
| 924 |
|
| 925 |
\c Section Install |
| 926 |
\c ${LineRead} "C:\a.log" "-1" $R0 |
| 927 |
\c ; $R0="Last line$\r$\n" |
| 928 |
\c SectionEnd |
| 929 |
|
| 930 |
\c Section un.Install |
| 931 |
\c ${TrimNewLines} "Last line$\r$\n" $R0 |
| 932 |
\c ; $R0="Last line" |
| 933 |
\c SectionEnd |
| 934 |
|
| 935 |
|
| 936 |
\S1{linefind} LineFind |
| 937 |
|
| 938 |
\b Find specified lines in text file, and edit or view these lines in callback function. |
| 939 |
|
| 940 |
\\<b\\>Syntax:\\</b\\> |
| 941 |
|
| 942 |
\c ${LineFind} "[File1]" "[File2|/NUL]" "[LineNumbers]" "Function" |
| 943 |
|
| 944 |
\c "[File1]" ; Input text file |
| 945 |
\c ; |
| 946 |
\c "[File2|/NUL]" ; [File2] |
| 947 |
\c ; Output text file |
| 948 |
\c ; If empty then File2=File1 |
| 949 |
\c ; [/NUL] |
| 950 |
\c ; No output text file (only read File1) |
| 951 |
\c ; |
| 952 |
\c "[LineNumbers]" ; [No|-No|No:No|{No}|{-No}|{No:No}] |
| 953 |
\c ; 1:-1 all lines to change (default) |
| 954 |
\c ; 2 second line from start |
| 955 |
\c ; -3 third line from end |
| 956 |
\c ; 5:9 range of lines from 5 to 9 |
| 957 |
\c ; {2} only second line from start to output |
| 958 |
\c ; {-3} only third line from end to output |
| 959 |
\c ; {5:9} only range of lines from 5 to 9 to output |
| 960 |
\c ; |
| 961 |
\c "Function" ; Callback function for specified lines |
| 962 |
\c |
| 963 |
\c Function "Function" |
| 964 |
\c ; $R9 current line |
| 965 |
\c ; $R8 current line number |
| 966 |
\c ; $R7 current line negative number |
| 967 |
\c ; $R6 current range of lines |
| 968 |
\c ; $R5 handle of a file opened to read |
| 969 |
\c ; $R4 handle of a file opened to write ($R4="" if "/NUL") |
| 970 |
\c |
| 971 |
\c ; you can use any string functions |
| 972 |
\c ; $R0-$R3 are not used (save data in them). |
| 973 |
\c ; ... |
| 974 |
\c |
| 975 |
\c Push $var ; If $var="StopLineFind" Then exit from function |
| 976 |
\c ; If $var="SkipWrite" Then skip current line (ignored if "/NUL") |
| 977 |
\c FunctionEnd |
| 978 |
|
| 979 |
\\<b\\>Note:\\</b\\> |
| 980 |
\\<br\\>- Error flag if input file doesn't exist |
| 981 |
\\<br\\>- Error flag if output file path doesn't exist |
| 982 |
\\<br\\>- Ranges must be specified on growth (2 4:5 9:-8 -5:-4 -2:-1) |
| 983 |
\\<br\\>- Output file will not be updated if no changes made. |
| 984 |
|
| 985 |
\\<b\\>Example1 (delete first two symbols):\\</b\\> |
| 986 |
|
| 987 |
\c Section |
| 988 |
\c ${LineFind} "C:\a.log" "C:\a-edited.log" "3:-1" "Example1" |
| 989 |
\c IfErrors 0 +2 |
| 990 |
\c MessageBox MB_OK "Error" |
| 991 |
\c SectionEnd |
| 992 |
\c |
| 993 |
\c Function Example1 |
| 994 |
\c ${TrimNewLines} '$R9' $R9 |
| 995 |
\c StrCpy $R9 $R9 '' 2 |
| 996 |
\c StrCpy $R9 '$R9$\r$\n' |
| 997 |
\c ;start from 3 line and delete first two symbols |
| 998 |
\c |
| 999 |
\c Push $0 |
| 1000 |
\c FunctionEnd |
| 1001 |
|
| 1002 |
\\<b\\>Example2 (show changed lines):\\</b\\> |
| 1003 |
|
| 1004 |
\c Section |
| 1005 |
\c ${LineFind} "C:\a.log" "a.log" "{5:12 15 -6:-5 -1}" "Example2" |
| 1006 |
\c IfErrors 0 +2 |
| 1007 |
\c MessageBox MB_OK "Error" |
| 1008 |
\c SectionEnd |
| 1009 |
\c |
| 1010 |
\c Function Example2 |
| 1011 |
\c ${TrimNewLines} '$R9' $R9 |
| 1012 |
\c StrCpy $R9 "$R9 ~Changed line ($R8)~$\r$\n" |
| 1013 |
\c |
| 1014 |
\c Push $0 |
| 1015 |
\c FunctionEnd |
| 1016 |
|
| 1017 |
\\<b\\>Example3 (delete lines):\\</b\\> |
| 1018 |
|
| 1019 |
\c Section |
| 1020 |
\c ${LineFind} "C:\a.log" "\logs\a.log" "2:3 10:-5 -3:-2" "Example3" |
| 1021 |
\c IfErrors 0 +2 |
| 1022 |
\c MessageBox MB_OK "Error" |
| 1023 |
\c SectionEnd |
| 1024 |
\c |
| 1025 |
\c Function Example3 |
| 1026 |
\c StrCpy $0 SkipWrite |
| 1027 |
\c |
| 1028 |
\c Push $0 |
| 1029 |
\c FunctionEnd |
| 1030 |
|
| 1031 |
\\<b\\>Example4 (insert lines):\\</b\\> |
| 1032 |
|
| 1033 |
\c Section |
| 1034 |
\c ${LineFind} "C:\a.log" "" "10" "Example4 |
| 1035 |
\c IfErrors 0 +2 |
| 1036 |
\c MessageBox MB_OK "Error" |
| 1037 |
\c SectionEnd |
| 1038 |
\c |
| 1039 |
\c Function Example4 |
| 1040 |
\c FileWrite $R4 "---First Line---$\r$\n" |
| 1041 |
\c FileWrite $R4 "---Second Line ...---$\r$\n" |
| 1042 |
\c |
| 1043 |
\c Push $0 |
| 1044 |
\c FunctionEnd |
| 1045 |
|
| 1046 |
\\<b\\>Example5 (replace in file with count of changes - "WordFunc.nsh" required):\\</b\\> |
| 1047 |
|
| 1048 |
\c !include "WordFunc.nsh" |
| 1049 |
\c |
| 1050 |
\c Section |
| 1051 |
\c StrCpy $R0 0 |
| 1052 |
\c ${LineFind} "C:\a.log" "C:\logs\a.log" "1:-1" "Example5" |
| 1053 |
\c IfErrors 0 +2 |
| 1054 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 1055 |
\c MessageBox MB_OK "Changed lines=$R0" |
| 1056 |
\c SectionEnd |
| 1057 |
\c |
| 1058 |
\c Function Example5 |
| 1059 |
\c StrCpy $1 $R9 |
| 1060 |
\c |
| 1061 |
\c ${WordReplace} '$R9' ' ' '_' '+*' $R9 |
| 1062 |
\c |
| 1063 |
\c StrCmp $1 $R9 +2 |
| 1064 |
\c IntOp $R0 $R0 + 1 |
| 1065 |
\c ;$R0 count of changed lines |
| 1066 |
\c |
| 1067 |
\c Push $0 |
| 1068 |
\c FunctionEnd |
| 1069 |
|
| 1070 |
\\<b\\>Example6 (line string to cut or delete):\\</b\\> |
| 1071 |
|
| 1072 |
\c Section |
| 1073 |
\c ${LineFind} "\a.log" "C:\logs\a.log" "" "Example6" |
| 1074 |
\c IfErrors 0 +2 |
| 1075 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 1076 |
\c MessageBox MB_OK "Processed lines=$R1:$R2" |
| 1077 |
\c SectionEnd |
| 1078 |
\c |
| 1079 |
\c Function Example6 |
| 1080 |
\c ;(Cut lines from a line to another line (also including that line)) |
| 1081 |
\c StrCmp $R0 finish stop |
| 1082 |
\c StrCmp $R0 start finish |
| 1083 |
\c StrCmp $R9 'Start Line$\r$\n' 0 skip |
| 1084 |
\c StrCpy $R0 start |
| 1085 |
\c StrCpy $R1 $R8 |
| 1086 |
\c goto code |
| 1087 |
\c finish: |
| 1088 |
\c StrCmp $R9 'Finish Line$\r$\n' 0 code |
| 1089 |
\c StrCpy $R0 finish |
| 1090 |
\c StrCpy $R2 $R8 |
| 1091 |
\c goto code |
| 1092 |
\c skip: |
| 1093 |
\c StrCpy $0 SkipWrite |
| 1094 |
\c goto output |
| 1095 |
\c stop: |
| 1096 |
\c StrCpy $0 StopLineFind |
| 1097 |
\c goto output |
| 1098 |
\c |
| 1099 |
\c ;;(Delete lines from a line to another line (also including that line)) |
| 1100 |
\c ; StrCmp $R0 finish code |
| 1101 |
\c ; StrCmp $R0 start finish |
| 1102 |
\c ; StrCmp $R9 'Start Line$\r$\n' 0 code |
| 1103 |
\c ; StrCpy $R0 start |
| 1104 |
\c ; StrCpy $R1 $R8 |
| 1105 |
\c ; goto skip |
| 1106 |
\c ; finish: |
| 1107 |
\c ; StrCmp $R9 'Finish Line$\r$\n' 0 skip |
| 1108 |
\c ; StrCpy $R0 finish |
| 1109 |
\c ; StrCpy $R2 $R8 |
| 1110 |
\c ; skip: |
| 1111 |
\c ; StrCpy $0 SkipWrite |
| 1112 |
\c ; goto output |
| 1113 |
\c |
| 1114 |
\c code: |
| 1115 |
\c ;... |
| 1116 |
\c |
| 1117 |
\c output: |
| 1118 |
\c Push $0 |
| 1119 |
\c FunctionEnd |
| 1120 |
|
| 1121 |
\\<b\\>Example7 (read lines):\\</b\\> |
| 1122 |
|
| 1123 |
\c Section |
| 1124 |
\c ${LineFind} "C:\a.log" "/NUL" "1:-1" "Example7" |
| 1125 |
\c IfErrors 0 +2 |
| 1126 |
\c MessageBox MB_OK "Error" |
| 1127 |
\c SectionEnd |
| 1128 |
\c |
| 1129 |
\c Function Example7 |
| 1130 |
\c MessageBox MB_OKCANCEL '$$R9 "Line"=[$R9]$\n$$R8 "#" =[$R8]' IDOK +2 |
| 1131 |
\c StrCpy $0 StopLineFind |
| 1132 |
\c |
| 1133 |
\c Push $0 |
| 1134 |
\c FunctionEnd |
| 1135 |
|
| 1136 |
\S1{lineread} LineRead |
| 1137 |
|
| 1138 |
\b Get line in file specified with number. |
| 1139 |
|
| 1140 |
\\<b\\>Syntax:\\</b\\> |
| 1141 |
|
| 1142 |
\c ${LineRead} "[File]" "[LineNumber]" $var |
| 1143 |
|
| 1144 |
\c "[File]" ; Input text file |
| 1145 |
\c ; |
| 1146 |
\c "[LineNumber]" ; [No|-No] |
| 1147 |
\c ; 3 line number from start |
| 1148 |
\c ; -5 line number from end |
| 1149 |
\c ; |
| 1150 |
\c $var ; Result: Line |
| 1151 |
|
| 1152 |
\\<b\\>Note:\\</b\\> |
| 1153 |
\\<br\\>- Error flag if input file doesn't exist |
| 1154 |
\\<br\\>- Error flag if line number not found |
| 1155 |
|
| 1156 |
\\<b\\>Example:\\</b\\> |
| 1157 |
|
| 1158 |
\c Section |
| 1159 |
\c ${LineRead} "C:\a.log" "-1" $R0 |
| 1160 |
\c ; $R0="Last line$\r$\n" |
| 1161 |
\c SectionEnd |
| 1162 |
|
| 1163 |
\S1{filereadfromend} FileReadFromEnd |
| 1164 |
|
| 1165 |
\b Read text file from end line by line. |
| 1166 |
|
| 1167 |
\\<b\\>Syntax:\\</b\\> |
| 1168 |
|
| 1169 |
\c ${FileReadFromEnd} "[File]" "Function" |
| 1170 |
|
| 1171 |
\c "[File]" ; Input text file |
| 1172 |
\c "Function" ; Callback function |
| 1173 |
\c |
| 1174 |
\c Function "Function" |
| 1175 |
\c ; $9 current line |
| 1176 |
\c ; $8 current line number |
| 1177 |
\c ; $7 current line negative number |
| 1178 |
\c |
| 1179 |
\c ; $R0-$R9 are not used (save data in them). |
| 1180 |
\c ; ... |
| 1181 |
\c |
| 1182 |
\c Push $var ; If $var="StopFileReadFromEnd" Then exit from function |
| 1183 |
\c FunctionEnd |
| 1184 |
|
| 1185 |
\\<b\\>Note:\\</b\\> |
| 1186 |
\\<br\\>- Error flag if input file doesn't exist |
| 1187 |
|
| 1188 |
\\<b\\>Example1:\\</b\\> |
| 1189 |
|
| 1190 |
\c Section |
| 1191 |
\c ${FileReadFromEnd} "C:\a.log" "Example1" |
| 1192 |
\c |
| 1193 |
\c IfErrors 0 +2 |
| 1194 |
\c MessageBox MB_OK "Error" |
| 1195 |
\c SectionEnd |
| 1196 |
\c |
| 1197 |
\c Function Example1 |
| 1198 |
\c MessageBox MB_OKCANCEL '"Line"=[$9]$\n "#"=[$8]$\n "-#"=[$7]' IDOK +2 |
| 1199 |
\c StrCpy $0 StopFileReadFromEnd |
| 1200 |
\c |
| 1201 |
\c Push $0 |
| 1202 |
\c FunctionEnd |
| 1203 |
|
| 1204 |
\\<b\\>Example2 (Reverse text file):\\</b\\> |
| 1205 |
|
| 1206 |
\c Section |
| 1207 |
\c GetTempFileName $R0 |
| 1208 |
\c FileOpen $R1 $R0 w |
| 1209 |
\c ${FileReadFromEnd} "C:\a.log" "Example2" |
| 1210 |
\c FileClose $R1 |
| 1211 |
\c |
| 1212 |
\c IfErrors 0 +2 |
| 1213 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 1214 |
\c Exec '"notepad.exe" "$R0"' |
| 1215 |
\c SectionEnd |
| 1216 |
\c |
| 1217 |
\c Function Example2 |
| 1218 |
\c StrCmp $7 -1 0 +5 |
| 1219 |
\c StrCpy $1 $9 1 -1 |
| 1220 |
\c StrCmp $1 '$\n' +3 |
| 1221 |
\c StrCmp $1 '$\r' +2 |
| 1222 |
\c StrCpy $9 '$9$\r$\n' |
| 1223 |
\c |
| 1224 |
\c FileWrite $R1 "$9" |
| 1225 |
\c |
| 1226 |
\c Push $0 |
| 1227 |
\c FunctionEnd |
| 1228 |
|
| 1229 |
\S1{linesum} LineSum |
| 1230 |
|
| 1231 |
\b Get sum of lines in text file. |
| 1232 |
|
| 1233 |
\\<b\\>Syntax:\\</b\\> |
| 1234 |
|
| 1235 |
\c ${LineSum} "[File]" $var |
| 1236 |
|
| 1237 |
\c "[File]" ; Input file |
| 1238 |
\c $var ; Result: Sum of lines |
| 1239 |
|
| 1240 |
\\<b\\>Note:\\</b\\> |
| 1241 |
\\<br\\>- Error flag if input file doesn't exist |
| 1242 |
|
| 1243 |
\\<b\\>Example:\\</b\\> |
| 1244 |
|
| 1245 |
\c Section |
| 1246 |
\c ${LineSum} "C:\a.log" $R0 |
| 1247 |
\c ; $R0="54" |
| 1248 |
\c SectionEnd |
| 1249 |
|
| 1250 |
\S1{filejoin} FileJoin |
| 1251 |
|
| 1252 |
\b Join two files in one (File1 + File2 = File3). |
| 1253 |
|
| 1254 |
\\<b\\>Syntax:\\</b\\> |
| 1255 |
|
| 1256 |
\c ${FileJoin} "[File1]" "[File2]" "[File3]" |
| 1257 |
|
| 1258 |
\c "[File1]" ; Input File1 |
| 1259 |
\c "[File2]" ; Input File2 |
| 1260 |
\c "[File3]" ; Output File3 |
| 1261 |
\c ; If [File3]="" Then add [File2] to [File1] |
| 1262 |
|
| 1263 |
\\<b\\>Note:\\</b\\> |
| 1264 |
\\<br\\>- Error flag if input files don't exist |
| 1265 |
\\<br\\>- Error flag if output file path doesn't exist |
| 1266 |
|
| 1267 |
\\<b\\>Example1 (Join: a.log + b.log = Z.log):\\</b\\> |
| 1268 |
|
| 1269 |
\c Section |
| 1270 |
\c ${FileJoin} "C:\a.log" "C:\logs\b.log" "C:\Z.log" |
| 1271 |
\c SectionEnd |
| 1272 |
|
| 1273 |
\\<b\\>Example2 (Add: a.log + b.log = a.log):\\</b\\> |
| 1274 |
|
| 1275 |
\c Section |
| 1276 |
\c ${FileJoin} "C:\a.log" "C:\logs\b.log" "C:\a.log" |
| 1277 |
\c SectionEnd |
| 1278 |
|
| 1279 |
\S1{textcompare} TextCompare |
| 1280 |
|
| 1281 |
\b Compare two text files. |
| 1282 |
|
| 1283 |
\\<b\\>Syntax:\\</b\\> |
| 1284 |
|
| 1285 |
\c ${TextCompare} "[File1]" "[File2]" "[Option]" "Function" |
| 1286 |
|
| 1287 |
\c "[File1]" ; File1 Compare these lines |
| 1288 |
\c "[File2]" ; File2 Compare with these lines |
| 1289 |
\c "[Options]" ; (line-by-line): |
| 1290 |
\c ; FastDiff Compare line N (File1) with line N (File2) |
| 1291 |
\c ; Call function if Different lines found |
| 1292 |
\c ; FastEqual Compare line N (File1) with line N (File2) |
| 1293 |
\c ; Call function if Equal lines found |
| 1294 |
\c ; (line number independent): |
| 1295 |
\c ; SlowDiff Compare line N (File1) with all lines (File2) |
| 1296 |
\c ; Call function if line N (File1) Different |
| 1297 |
\c ; SlowEqual Compare line N (File1) with all lines (File2) |
| 1298 |
\c ; Call function if line N (File1) Equal |
| 1299 |
\c "Function" ; Callback function |
| 1300 |
\c |
| 1301 |
\c Function "Function" |
| 1302 |
\c ; $9 "Line File1" |
| 1303 |
\c ; $8 "Line number" |
| 1304 |
\c ; $7 "Line File2" (empty if SlowDiff) |
| 1305 |
\c ; $6 "Line number" (empty if SlowDiff) |
| 1306 |
\c |
| 1307 |
\c ; $R0-$R9 are not used (save data in them). |
| 1308 |
\c ; ... |
| 1309 |
\c |
| 1310 |
\c Push $var ; If $var="StopTextCompare" Then exit from function |
| 1311 |
\c FunctionEnd |
| 1312 |
|
| 1313 |
\\<b\\>Note:\\</b\\> |
| 1314 |
\\<br\\>- Error flag if File1 or File2 doesn't exist |
| 1315 |
\\<br\\>- Error flag if syntax error |
| 1316 |
|
| 1317 |
\\<b\\>Example (Different or Equal):\\</b\\> |
| 1318 |
|
| 1319 |
\c Section |
| 1320 |
\c StrCpy $R0 '' |
| 1321 |
\c ${TextCompare} "C:\1.txt" "C:\2.txt" "FastDiff" "Example1" |
| 1322 |
\c IfErrors 0 +2 |
| 1323 |
\c MessageBox MB_OK "Error" IDOK +4 |
| 1324 |
\c |
| 1325 |
\c StrCmp $R0 NotEqual 0 +2 |
| 1326 |
\c MessageBox MB_OK "Files differ" IDOK +2 |
| 1327 |
\c MessageBox MB_OK "Files identical" |
| 1328 |
\c SectionEnd |
| 1329 |
\c |
| 1330 |
\c Function Example1 |
| 1331 |
\c StrCpy $R0 NotEqual |
| 1332 |
\c StrCpy $0 StopTextCompare |
| 1333 |
\c |
| 1334 |
\c Push $0 |
| 1335 |
\c FunctionEnd |
| 1336 |
|
| 1337 |
\\<b\\>Example (Compare line-by-line - Different):\\</b\\> |
| 1338 |
|
| 1339 |
\c Section |
| 1340 |
\c StrCpy $R0 'Text1.txt' |
| 1341 |
\c StrCpy $R1 'Text2.txt' |
| 1342 |
\c |
| 1343 |
\c GetTempFileName $R2 |
| 1344 |
\c FileOpen $R3 $R2 w |
| 1345 |
\c FileWrite $R3 "$R0 | $R1$\r$\n" |
| 1346 |
\c ${TextCompare} "$R0" "$R1" "FastDiff" "Example2" |
| 1347 |
\c IfErrors 0 +2 |
| 1348 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 1349 |
\c |
| 1350 |
\c Exec "notepad.exe $R2" |
| 1351 |
\c FunctionEnd |
| 1352 |
\c |
| 1353 |
\c Function Example2 |
| 1354 |
\c FileWrite $R3 '$8=$9' |
| 1355 |
\c FileWrite $R3 '$6=$7$\r$\n' |
| 1356 |
\c |
| 1357 |
\c Push $0 |
| 1358 |
\c FunctionEnd |
| 1359 |
|
| 1360 |
\\<b\\>Example (Compare line-by-line - Equal):\\</b\\> |
| 1361 |
|
| 1362 |
\c Section |
| 1363 |
\c StrCpy $R0 'Text1.txt' |
| 1364 |
\c StrCpy $R1 'Text2.txt' |
| 1365 |
\c |
| 1366 |
\c GetTempFileName $R2 |
| 1367 |
\c FileOpen $R3 $R2 w |
| 1368 |
\c FileWrite $R3 "$R0 | $R1$\r$\n" |
| 1369 |
\c ${TextCompare} "$R0" "$R1" "FastEqual" "Example3" |
| 1370 |
\c IfErrors 0 +2 |
| 1371 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 1372 |
\c |
| 1373 |
\c Exec "notepad.exe $R2" |
| 1374 |
\c FunctionEnd |
| 1375 |
\c |
| 1376 |
\c Function Example3 |
| 1377 |
\c FileWrite $R3 '$8|$6=$9' |
| 1378 |
\c |
| 1379 |
\c Push $0 |
| 1380 |
\c FunctionEnd |
| 1381 |
|
| 1382 |
\\<b\\>Example (Compare all lines - Different):\\</b\\> |
| 1383 |
|
| 1384 |
\c Section |
| 1385 |
\c StrCpy $R0 'Text1.txt' |
| 1386 |
\c StrCpy $R1 'Text2.txt' |
| 1387 |
\c |
| 1388 |
\c GetTempFileName $R2 |
| 1389 |
\c FileOpen $R3 $R2 w |
| 1390 |
\c FileWrite $R3 "$R0 | $R1$\r$\n" |
| 1391 |
\c ${TextCompare} "$R0" "$R1" "SlowDiff" "Example4" |
| 1392 |
\c IfErrors 0 +2 |
| 1393 |
\c MessageBox MB_OK "Error" IDOK end |
| 1394 |
\c |
| 1395 |
\c FileWrite $R3 "$\r$\n$R1 | $R0$\r$\n" |
| 1396 |
\c ${TextCompare} "$R1" "$R0" "SlowDiff" "Example4" |
| 1397 |
\c FileClose $R3 |
| 1398 |
\c IfErrors 0 +2 |
| 1399 |
\c MessageBox MB_OK "Error" IDOK end |
| 1400 |
\c |
| 1401 |
\c Exec "notepad.exe $R2" |
| 1402 |
\c |
| 1403 |
\c end: |
| 1404 |
\c FunctionEnd |
| 1405 |
\c |
| 1406 |
\c Function Example4 |
| 1407 |
\c FileWrite $R3 '$8=$9' |
| 1408 |
\c |
| 1409 |
\c Push $0 |
| 1410 |
\c FunctionEnd |
| 1411 |
|
| 1412 |
\\<b\\>Example (Compare all lines - Equal):\\</b\\> |
| 1413 |
|
| 1414 |
\c Section |
| 1415 |
\c StrCpy $R0 'Text1.txt' |
| 1416 |
\c StrCpy $R1 'Text2.txt' |
| 1417 |
\c |
| 1418 |
\c GetTempFileName $R2 |
| 1419 |
\c FileOpen $R3 $R2 w |
| 1420 |
\c FileWrite $R3 "$R0 | $R1$\r$\n" |
| 1421 |
\c ${TextCompare} "$R0" "$R1" "SlowEqual" "Example5" |
| 1422 |
\c IfErrors 0 +2 |
| 1423 |
\c MessageBox MB_OK "Error" IDOK +2 |
| 1424 |
\c |
| 1425 |
\c Exec "notepad.exe $R2" |
| 1426 |
\c FunctionEnd |
| 1427 |
\c |
| 1428 |
\c Function Example5 |
| 1429 |
\c FileWrite $R3 '$8|$6=$9' |
| 1430 |
\c |
| 1431 |
\c Push $0 |
| 1432 |
\c FunctionEnd |
| 1433 |
|
| 1434 |
\\<b\\>Example (Show variables):\\</b\\> |
| 1435 |
|
| 1436 |
\c Section |
| 1437 |
\c ${TextCompare} "C:\1.txt" "C:\2.txt" "FastDiff" "Example6" |
| 1438 |
\c |
| 1439 |
\c IfErrors 0 +2 |
| 1440 |
\c MessageBox MB_OK "Error" |
| 1441 |
\c SectionEnd |
| 1442 |
\c |
| 1443 |
\c Function Example6 |
| 1444 |
\c MessageBox MB_OKCANCEL '\ |
| 1445 |
\c $$9 "Line File1" =[$9]$\n\ |
| 1446 |
\c $$8 "Line #" =[$8]$\n\ |
| 1447 |
\c $$7 "Line File2" =[$7]$\n\ |
| 1448 |
\c $$6 "Line #" =[$6]'\ |
| 1449 |
\c IDOK +2 |
| 1450 |
\c StrCpy $0 StopTextCompare |
| 1451 |
\c |
| 1452 |
\c Push $0 |
| 1453 |
\c FunctionEnd |
| 1454 |
|
| 1455 |
\S1{textcompares} TextCompareS |
| 1456 |
|
| 1457 |
\b Same as \R{textcompare}{TextCompare}, but case sensitive. |
| 1458 |
|
| 1459 |
\S1{configread} ConfigRead |
| 1460 |
|
| 1461 |
\b Read value from entry name in config file. |
| 1462 |
|
| 1463 |
\\<b\\>Syntax:\\</b\\> |
| 1464 |
|
| 1465 |
\c ${ConfigRead} "[File]" "[Entry]" $var |
| 1466 |
|
| 1467 |
\c "[File]" ; config file |
| 1468 |
\c ; |
| 1469 |
\c "[Entry]" ; entry name |
| 1470 |
\c ; |
| 1471 |
\c $var ; Result: Value |
| 1472 |
|
| 1473 |
\\<b\\>Note:\\</b\\> |
| 1474 |
\\<br\\>- Error flag if entry not found |
| 1475 |
\\<br\\>- Error flag if file doesn't exist |
| 1476 |
|
| 1477 |
\\<b\\>Example1:\\</b\\> |
| 1478 |
|
| 1479 |
\c Section |
| 1480 |
\c ${ConfigRead} "C:\AUTOEXEC.BAT" "SET winbootdir=" $R0 |
| 1481 |
\c ;$R0=C:\WINDOWS |
| 1482 |
\c SectionEnd |
| 1483 |
|
| 1484 |
\\<b\\>Example2:\\</b\\> |
| 1485 |
|
| 1486 |
\c Section |
| 1487 |
\c ${ConfigRead} "C:\apache\conf\httpd.conf" "Timeout " $R0 |
| 1488 |
\c ;$R0=30 |
| 1489 |
\c SectionEnd |
| 1490 |
|
| 1491 |
\S1{configreads} ConfigReadS |
| 1492 |
|
| 1493 |
\b Same as \R{configread}{ConfigRead}, but case sensitive. |
| 1494 |
|
| 1495 |
\S1{configwrite} ConfigWrite |
| 1496 |
|
| 1497 |
\b Write value from entry name in config file. |
| 1498 |
|
| 1499 |
\\<b\\>Syntax:\\</b\\> |
| 1500 |
|
| 1501 |
\c ${ConfigWrite} "[File]" "[Entry]" "[Value]" $var |
| 1502 |
|
| 1503 |
\c "[File]" ; config file |
| 1504 |
\c ; |
| 1505 |
\c "[Entry]" ; entry name |
| 1506 |
\c ; |
| 1507 |
\c "[Value]" ; value name |
| 1508 |
\c ; if "" then delete Entry |
| 1509 |
\c ; |
| 1510 |
\c $var ; Result: |
| 1511 |
\c ; $var=CHANGED Value is written |
| 1512 |
\c ; $var=DELETED Entry is deleted |
| 1513 |
\c ; $var=ADDED Entry and Value are added |
| 1514 |
\c ; $var=SAME Entry and Value already exist |
| 1515 |
|
| 1516 |
\\<b\\>Note:\\</b\\> |
| 1517 |
\\<br\\>- Error flag if file doesn't exist |
| 1518 |
\\<br\\>- Error flag if file can't be opened |
| 1519 |
|
| 1520 |
\\<b\\>Example1:\\</b\\> |
| 1521 |
|
| 1522 |
\c Section |
| 1523 |
\c ${ConfigWrite} "C:\AUTOEXEC.BAT" "SET winbootdir=" "D:\WINDOWS" $R0 |
| 1524 |
\c ;$R0=CHANGED |
| 1525 |
\c SectionEnd |
| 1526 |
|
| 1527 |
\\<b\\>Example2:\\</b\\> |
| 1528 |
|
| 1529 |
\c Section |
| 1530 |
\c ${ConfigWrite} "C:\apache\conf\httpd.conf" "Timeout " "30" $R0 |
| 1531 |
\c ;$R0=SAME |
| 1532 |
\c SectionEnd |
| 1533 |
|
| 1534 |
\\<b\\>Example3:\\</b\\> |
| 1535 |
|
| 1536 |
\c Section |
| 1537 |
\c ${ConfigWrite} "C:\apache\conf\httpd.conf" "Timeout " "" $R0 |
| 1538 |
\c ;$R0=DELETED |
| 1539 |
\c SectionEnd |
| 1540 |
|
| 1541 |
\S1{configwrites} ConfigWriteS |
| 1542 |
|
| 1543 |
\b Same as \R{configwrite}{ConfigWrite}, but case sensitive. |
| 1544 |
|
| 1545 |
\S1{filerecode} FileRecode |
| 1546 |
|
| 1547 |
\b Recode text file from DOS to Windows format and vice-versa. |
| 1548 |
|
| 1549 |
\\<b\\>Syntax:\\</b\\> |
| 1550 |
|
| 1551 |
\c ${FileRecode} "[File]" "[Format]" |
| 1552 |
|
| 1553 |
\c "[File]" ; |
| 1554 |
\c ; |
| 1555 |
\c "[Format]" ; OemToChar -from DOS to Windows |
| 1556 |
\c ; CharToOem -from Windows to DOS |
| 1557 |
|
| 1558 |
\\<b\\>Note:\\</b\\> |
| 1559 |
\\<br\\>- Error flag if file doesn't exist |
| 1560 |
\\<br\\>- Error flag if syntax error |
| 1561 |
|
| 1562 |
\\<b\\>Example:\\</b\\> |
| 1563 |
|
| 1564 |
\c Section |
| 1565 |
\c ${FileRecode} "C:\SCANDISK.LOG" "CharToOem" |
| 1566 |
\c SectionEnd |
| 1567 |
|
| 1568 |
\S1{trimnewlines} TrimNewLines |
| 1569 |
|
| 1570 |
\b Trim newlines in a string. |
| 1571 |
|
| 1572 |
\\<b\\>Syntax:\\</b\\> |
| 1573 |
|
| 1574 |
\c ${TrimNewLines} "[string]" $var |
| 1575 |
|
| 1576 |
\c "[string]" ; Input string |
| 1577 |
\c $var ; Result: String without '$\r' and '$\n' at the end |
| 1578 |
|
| 1579 |
\\<b\\>Example:\\</b\\> |
| 1580 |
|
| 1581 |
\c Section |
| 1582 |
\c ${TrimNewLines} "Text line$\r$\n" $R0 |
| 1583 |
\c ; $R0="Text line" |
| 1584 |
\c SectionEnd |
| 1585 |
|
| 1586 |
|
| 1587 |
\H{wordfunc} Word Functions Header |
| 1588 |
|
| 1589 |
|
| 1590 |
\S1{} Introduction |
| 1591 |
|
| 1592 |
Include header: |
| 1593 |
|
| 1594 |
\c !include "WordFunc.nsh" |
| 1595 |
|
| 1596 |
Call functions: |
| 1597 |
|
| 1598 |
\c Section Install |
| 1599 |
\c ${WordFind} "A--H---S" "-" "+2" $R0 |
| 1600 |
\c ; $R0="H" |
| 1601 |
\c SectionEnd |
| 1602 |
|
| 1603 |
\c Section un.Install |
| 1604 |
\c ${WordReplace} "A--H---S" "-" "x" "+3*" $R0 |
| 1605 |
\c ; $R0="A--HxS" |
| 1606 |
\c SectionEnd |
| 1607 |
|
| 1608 |
|
| 1609 |
\S1{wordfind} WordFind |
| 1610 |
|
| 1611 |
\b Multi-features string function. |
| 1612 |
|
| 1613 |
\c Strings: |
| 1614 |
\c "[word+1][delimiter][word+2][delimiter][word+3]..." |
| 1615 |
\c "[delimiter][word+1][delimiter][word+2][delimiter]..." |
| 1616 |
\c "[delimiter][delimiter][word+1][delimiter][delimiter][delimiter]..." |
| 1617 |
\c "...[word-3][delimiter][word-2][delimiter][word-1]" |
| 1618 |
\c "...[delimiter][word-2][delimiter][word-1][delimiter]" |
| 1619 |
\c "...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]" |
| 1620 |
|
| 1621 |
\\<b\\>Syntax: \\</b\\> |
| 1622 |
|
| 1623 |
\c ${WordFind} "[string]" "[delimiter]" "[E][options]" $var |
| 1624 |
|
| 1625 |
\c "[string]" ;[string] |
| 1626 |
\c ; input string |
| 1627 |
\c "[delimiter]" ;[delimiter] |
| 1628 |
\c ; one or several symbols |
| 1629 |
\c "[E][options]" ;[options] |
| 1630 |
\c ; +number : word number from start |
| 1631 |
\c ; -number : word number from end |
| 1632 |
\c ; +number} : delimiter number from start |
| 1633 |
\c ; all space after this |
| 1634 |
\c ; delimiter to output |
| 1635 |
\c ; +number{ : delimiter number from start |
| 1636 |
\c ; all space before this |
| 1637 |
\c ; delimiter to output |
| 1638 |
\c ; +number}} : word number from start |
| 1639 |
\c ; all space after this word |
| 1640 |
\c ; to output |
| 1641 |
\c ; +number{{ : word number from start |
| 1642 |
\c ; all space before this word |
| 1643 |
\c ; to output |
| 1644 |
\c ; +number{} : word number from start |
| 1645 |
\c ; all space before and after |
| 1646 |
\c ; this word (word exclude) |
| 1647 |
\c ; +number*} : word number from start |
| 1648 |
\c ; all space after this |
| 1649 |
\c ; word to output with word |
| 1650 |
\c ; +number{* : word number from start |
| 1651 |
\c ; all space before this |
| 1652 |
\c ; word to output with word |
| 1653 |
\c ; # : sum of words to output |
| 1654 |
\c ; * : sum of delimiters to output |
| 1655 |
\c ; /word : number of word to output |
| 1656 |
\c ; |
| 1657 |
\c ;[E] |
| 1658 |
\c ; with errorlevel output |
| 1659 |
\c ; IfErrors: |
| 1660 |
\c ; $var=1 delimiter not found |
| 1661 |
\c ; $var=2 no such word number |
| 1662 |
\c ; $var=3 syntax error (Use: +1,-1},#,*,/word,...) |
| 1663 |
\c ;[] |
| 1664 |
\c ; no errorlevel output (default) |
| 1665 |
\c ; If some errors found then (result=input string) |
| 1666 |
\c ; |
| 1667 |
\c $var ;output (result) |
| 1668 |
|
| 1669 |
\\<b\\>Note:\\</b\\> |
| 1670 |
\\<br\\>- Accepted numbers 1,01,001,... |
| 1671 |
|
| 1672 |
\\<b\\>Example (Find word by number):\\</b\\> |
| 1673 |
|
| 1674 |
\c Section |
| 1675 |
\c ${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " C:\" "-02" $R0 |
| 1676 |
\c ; $R0="Program Files" |
| 1677 |
\c SectionEnd |
| 1678 |
|
| 1679 |
\\<b\\>Example (Delimiter exclude):\\</b\\> |
| 1680 |
|
| 1681 |
\c Section |
| 1682 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "-2}" $R0 |
| 1683 |
\c ; $R0=" C:\logo.sys C:\WINDOWS" |
| 1684 |
\c SectionEnd |
| 1685 |
|
| 1686 |
\\<b\\>Example (Sum of words):\\</b\\> |
| 1687 |
|
| 1688 |
\c Section |
| 1689 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $R0 |
| 1690 |
\c ; $R0="3" |
| 1691 |
\c SectionEnd |
| 1692 |
|
| 1693 |
\\<b\\>Example (Sum of delimiters):\\</b\\> |
| 1694 |
|
| 1695 |
\c Section |
| 1696 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0 |
| 1697 |
\c ; $R0="2" |
| 1698 |
\c SectionEnd |
| 1699 |
|
| 1700 |
\\<b\\>Example (Find word number):\\</b\\> |
| 1701 |
|
| 1702 |
\c Section |
| 1703 |
\c ${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " " "/Files" $R0 |
| 1704 |
\c ; $R0="3" |
| 1705 |
\c SectionEnd |
| 1706 |
|
| 1707 |
\\<b\\>Example ( \}\} ):\\</b\\> |
| 1708 |
|
| 1709 |
\c Section |
| 1710 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2}}" $R0 |
| 1711 |
\c ; $R0=" C:\WINDOWS" |
| 1712 |
\c SectionEnd |
| 1713 |
|
| 1714 |
\\<b\\>Example ( \{\} ):\\</b\\> |
| 1715 |
|
| 1716 |
\c Section |
| 1717 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2{}" $R0 |
| 1718 |
\c ; $R0="C:\io.sys C:\WINDOWS" |
| 1719 |
\c SectionEnd |
| 1720 |
|
| 1721 |
\\<b\\>Example ( *\} ):\\</b\\> |
| 1722 |
|
| 1723 |
\c Section |
| 1724 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2*}" $R0 |
| 1725 |
\c ; $R0="C:\logo.sys C:\WINDOWS" |
| 1726 |
\c SectionEnd |
| 1727 |
|
| 1728 |
\\<b\\>Example (Get parent directory):\\</b\\> |
| 1729 |
|
| 1730 |
\c Section |
| 1731 |
\c StrCpy $R0 "C:\Program Files\NSIS\NSIS.chm" |
| 1732 |
\c ; "C:\Program Files\NSIS\Include\" |
| 1733 |
\c ; "C:\\Program Files\\NSIS\\NSIS.chm" |
| 1734 |
\c |
| 1735 |
\c ${WordFind} "$R0" "\" "-2{*" $R0 |
| 1736 |
\c ; $R0="C:\Program Files\NSIS" |
| 1737 |
\c ; "C:\\Program Files\\NSIS" |
| 1738 |
\c SectionEnd |
| 1739 |
|
| 1740 |
\\<b\\>Example (Coordinates):\\</b\\> |
| 1741 |
|
| 1742 |
\c Section |
| 1743 |
\c ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" ":\lo" "E+1{" $R0 |
| 1744 |
\c ; $R0="C:\io.sys C" |
| 1745 |
\c IfErrors end |
| 1746 |
\c |
| 1747 |
\c StrLen $0 $R0 ; $0 = Start position of word (11) |
| 1748 |
\c StrLen $1 ':\lo' ; $1 = Word length (4) |
| 1749 |
\c ; StrCpy $R0 $R1 $1 $0 ; $R0 = :\lo |
| 1750 |
\c |
| 1751 |
\c end: |
| 1752 |
\c SectionEnd |
| 1753 |
|
| 1754 |
\\<b\\>Example (With errorlevel output):\\</b\\> |
| 1755 |
|
| 1756 |
\c Section |
| 1757 |
\c ${WordFind} "[string]" "[delimiter]" "E[options]" $R0 |
| 1758 |
\c |
| 1759 |
\c IfErrors 0 end |
| 1760 |
\c StrCmp $R0 1 0 +2 ; errorlevel 1? |
| 1761 |
\c MessageBox MB_OK 'delimiter not found' IDOK end |
| 1762 |
\c StrCmp $R0 2 0 +2 ; errorlevel 2? |
| 1763 |
\c MessageBox MB_OK 'no such word number' IDOK end |
| 1764 |
\c StrCmp $R0 3 0 +2 ; errorlevel 3? |
| 1765 |
\c MessageBox MB_OK 'syntax error' |
| 1766 |
\c |
| 1767 |
\c end: |
| 1768 |
\c SectionEnd |
| 1769 |
|
| 1770 |
\\<b\\>Example (Without errorlevel output):\\</b\\> |
| 1771 |
|
| 1772 |
\c Section |
| 1773 |
\c ${WordFind} "C:\io.sys C:\logo.sys" "_" "+1" $R0 |
| 1774 |
\c |
| 1775 |
\c ; $R0="C:\io.sys C:\logo.sys" (error: delimiter "_" not found) |
| 1776 |
\c SectionEnd |
| 1777 |
|
| 1778 |
\\<b\\>Example (If found):\\</b\\> |
| 1779 |
|
| 1780 |
\c Section |
| 1781 |
\c ${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "E+1{" $R0 |
| 1782 |
\c |
| 1783 |
\c IfErrors notfound found |
| 1784 |
\c found: |
| 1785 |
\c MessageBox MB_OK 'Found' IDOK end |
| 1786 |
\c notfound: |
| 1787 |
\c MessageBox MB_OK 'Not found' |
| 1788 |
\c |
| 1789 |
\c end: |
| 1790 |
\c SectionEnd |
| 1791 |
|
| 1792 |
\\<b\\>Example (If found 2):\\</b\\> |
| 1793 |
|
| 1794 |
\c Section |
| 1795 |
\c ${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "+1{" $R0 |
| 1796 |
\c |
| 1797 |
\c StrCmp $R0 "C:\io.sys C:\logo.sys" notfound found ; error? |
| 1798 |
\c found: |
| 1799 |
\c MessageBox MB_OK 'Found' IDOK end |
| 1800 |
\c notfound: |
| 1801 |
\c MessageBox MB_OK 'Not found' |
| 1802 |
\c |
| 1803 |
\c end: |
| 1804 |
\c SectionEnd |
| 1805 |
|
| 1806 |
\\<b\\>Example (To accept one word in string if delimiter not found):\\</b\\> |
| 1807 |
|
| 1808 |
\c Section |
| 1809 |
\c StrCpy $0 'OneWord' |
| 1810 |
\c StrCpy $1 1 |
| 1811 |
\c |
| 1812 |
\c loop: |
| 1813 |
\c ${WordFind} "$0" " " "E+$1" $R0 |
| 1814 |
\c IfErrors 0 code |
| 1815 |
\c StrCmp $1$R0 11 0 error |
| 1816 |
\c StrCpy $R0 $0 |
| 1817 |
\c goto end |
| 1818 |
\c |
| 1819 |
\c code: |
| 1820 |
\c ; ... |
| 1821 |
\c IntOp $1 $1 + 1 |
| 1822 |
\c goto loop |
| 1823 |
\c |
| 1824 |
\c error: |
| 1825 |
\c StrCpy $1 '' |
| 1826 |
\c StrCpy $R0 '' |
| 1827 |
\c |
| 1828 |
\c end: |
| 1829 |
\c ; $R0="OneWord" |
| 1830 |
\c SectionEnd |
| 1831 |
|
| 1832 |
\S1{wordfinds} WordFindS |
| 1833 |
|
| 1834 |
\b Same as \R{wordfind}{WordFind}, but case sensitive. |
| 1835 |
|
| 1836 |
\S1{wordfind2x} WordFind2X |
| 1837 |
|
| 1838 |
\b Find word between two delimiters. |
| 1839 |
|
| 1840 |
\c Strings: |
| 1841 |
\c "[delimiter1][word+1][delimiter2][delimiter1][word+2][delimiter2]..." |
| 1842 |
\c "[text][delimiter1][text][delimiter1][word+1][delimiter2][text]..." |
| 1843 |
\c "...[delimiter1][word-2][delimiter2][delimiter1][word-1][delimiter2]" |
| 1844 |
\c "...[text][delimiter1][text][delimiter1][word-1][delimiter2][text]" |
| 1845 |
|
| 1846 |
\\<b\\>Syntax:\\</b\\> |
| 1847 |
|
| 1848 |
\c ${WordFind2X} "[string]" "[delimiter1]" "[delimiter2]" "[E][options]" $var |
| 1849 |
|
| 1850 |
\c "[string]" ;[string] |
| 1851 |
\c ; input string |
| 1852 |
\c "[delimiter1]" ;[delimiter1] |
| 1853 |
\c ; first delimiter |
| 1854 |
\c "[delimiter2]" ;[delimiter2] |
| 1855 |
\c ; second delimiter |
| 1856 |
\c "[E][options]" ;[options] |
| 1857 |
\c ; +number : word number from start |
| 1858 |
\c ; -number : word number from end |
| 1859 |
\c ; +number}} : word number from start all space |
| 1860 |
\c ; after this word to output |
| 1861 |
\c ; +number{{ : word number from end all space |
| 1862 |
\c ; before this word to output |
| 1863 |
\c ; +number{} : word number from start |
| 1864 |
\c ; all space before and after |
| 1865 |
\c ; this word (word exclude) |
| 1866 |
\c ; +number*} : word number from start |
| 1867 |
\c ; all space after this |
| 1868 |
\c ; word to output with word |
| 1869 |
\c ; +number{* : word number from start |
| 1870 |
\c ; all space before this |
| 1871 |
\c ; word to output with word |
| 1872 |
\c ; # : sum of words to output |
| 1873 |
\c ; /word : number of word to output |
| 1874 |
\c ; |
| 1875 |
\c ;[E] |
| 1876 |
\c ; with errorlevel output |
| 1877 |
\c ; IfErrors: |
| 1878 |
\c ; $var=1 no words found |
| 1879 |
\c ; $var=2 no such word number |
| 1880 |
\c ; $var=3 syntax error (Use: +1,-1,#) |
| 1881 |
\c ;[] |
| 1882 |
\c ; no errorlevel output (default) |
| 1883 |
\c ; If some errors found then (result=input string) |
| 1884 |
\c ; |
| 1885 |
\c $var ;output (result) |
| 1886 |
|
| 1887 |
\\<b\\>Example (1):\\</b\\> |
| 1888 |
|
| 1889 |
\c Section |
| 1890 |
\c ${WordFind2X} "[C:\io.sys];[C:\logo.sys];[C:\WINDOWS]" "[C:\" "];" "+2" $R0 |
| 1891 |
\c ; $R0="logo.sys" |
| 1892 |
\c SectionEnd |
| 1893 |
|
| 1894 |
\\<b\\>Example (2):\\</b\\> |
| 1895 |
|
| 1896 |
\c Section |
| 1897 |
\c ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1" $R0 |
| 1898 |
\c ; $R0="logo" |
| 1899 |
\c SectionEnd |
| 1900 |
|
| 1901 |
\\<b\\>Example (3):\\</b\\> |
| 1902 |
|
| 1903 |
\c Section |
| 1904 |
\c ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{{" $R0 |
| 1905 |
\c ; $R0="C:\WINDOWS C:\io.sys C:" |
| 1906 |
\c SectionEnd |
| 1907 |
|
| 1908 |
\\<b\\>Example (4):\\</b\\> |
| 1909 |
|
| 1910 |
\c Section |
| 1911 |
\c ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{}" $R0 |
| 1912 |
\c ; $R0="C:\WINDOWS C:\io.sys C:sys" |
| 1913 |
\c SectionEnd |
| 1914 |
|
| 1915 |
\\<b\\>Example (5):\\</b\\> |
| 1916 |
|
| 1917 |
\c Section |
| 1918 |
\c ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{*" $R0 |
| 1919 |
\c ; $R0="C:\WINDOWS C:\io.sys C:\logo." |
| 1920 |
\c SectionEnd |
| 1921 |
|
| 1922 |
\\<b\\>Example (6):\\</b\\> |
| 1923 |
|
| 1924 |
\c Section |
| 1925 |
\c ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "/logo" $R0 |
| 1926 |
\c ; $R0="2" |
| 1927 |
\c SectionEnd |
| 1928 |
|
| 1929 |
\\<b\\>Example (With errorlevel output):\\</b\\> |
| 1930 |
|
| 1931 |
\c Section |
| 1932 |
\c ${WordFind2X} "[io.sys];[C:\logo.sys]" "\" "];" "E+1" $R0 |
| 1933 |
\c ; $R0="1" ("\...];" not found) |
| 1934 |
\c |
| 1935 |
\c IfErrors 0 noerrors |
| 1936 |
\c MessageBox MB_OK 'Errorlevel=$R0' IDOK end |
| 1937 |
\c |
| 1938 |
\c noerrors: |
| 1939 |
\c MessageBox MB_OK 'No errors' |
| 1940 |
\c |
| 1941 |
\c end: |
| 1942 |
\c SectionEnd |
| 1943 |
|
| 1944 |
\S1{wordfind2xs} WordFind2XS |
| 1945 |
|
| 1946 |
\b Same as \R{wordfind2x}{WordFind2X}, but case sensitive. |
| 1947 |
|
| 1948 |
\S1{wordfind3x} WordFind3X |
| 1949 |
|
| 1950 |
\b Find a word that contains a string, between two delimiters. |
| 1951 |
|
| 1952 |
\\<b\\>Syntax:\\</b\\> |
| 1953 |
|
| 1954 |
\c ${WordFind3X} "[string]" "[delimiter1]" "[center]" "[delimiter2]" "[E][options]" $var |
| 1955 |
|
| 1956 |
\c "[string]" ;[string] |
| 1957 |
\c ; input string |
| 1958 |
\c "[delimiter1]" ;[delimiter1] |
| 1959 |
\c ; first delimiter |
| 1960 |
\c "[center]" ;[center] |
| 1961 |
\c ; center string |
| 1962 |
\c "[delimiter2]" ;[delimiter2] |
| 1963 |
\c ; second delimiter |
| 1964 |
\c "[E][options]" ;[options] |
| 1965 |
\c ; +number : word number from start |
| 1966 |
\c ; -number : word number from end |
| 1967 |
\c ; +number}} : word number from start all space |
| 1968 |
\c ; after this word to output |
| 1969 |
\c ; +number{{ : word number from end all space |
| 1970 |
\c ; before this word to output |
| 1971 |
\c ; +number{} : word number from start |
| 1972 |
\c ; all space before and after |
| 1973 |
\c ; this word (word exclude) |
| 1974 |
\c ; +number*} : word number from start |
| 1975 |
\c ; all space after this |
| 1976 |
\c ; word to output with word |
| 1977 |
\c ; +number{* : word number from start |
| 1978 |
\c ; all space before this |
| 1979 |
\c ; word to output with word |
| 1980 |
\c ; # : sum of words to output |
| 1981 |
\c ; /word : number of word to output |
| 1982 |
\c ; |
| 1983 |
\c ;[E] |
| 1984 |
\c ; with errorlevel output |
| 1985 |
\c ; IfErrors: |
| 1986 |
\c ; $var=1 no words found |
| 1987 |
\c ; $var=2 no such word number |
| 1988 |
\c ; $var=3 syntax error (Use: +1,-1,#) |
| 1989 |
\c ;[] |
| 1990 |
\c ; no errorlevel output (default) |
| 1991 |
\c ; If some errors found then (result=input string) |
| 1992 |
\c ; |
| 1993 |
\c $var ;output (result) |
| 1994 |
|
| 1995 |
\\<b\\>Example (1):\\</b\\> |
| 1996 |
|
| 1997 |
\c Section |
| 1998 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "+1" $R0 |
| 1999 |
\c ; $R0="1.AAB" |
| 2000 |
\c SectionEnd |
| 2001 |
|
| 2002 |
\\<b\\>Example (2):\\</b\\> |
| 2003 |
|
| 2004 |
\c Section |
| 2005 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1" $R0 |
| 2006 |
\c ; $R0="2.BAA" |
| 2007 |
\c SectionEnd |
| 2008 |
|
| 2009 |
\\<b\\>Example (3):\\</b\\> |
| 2010 |
|
| 2011 |
\c Section |
| 2012 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{{" $R0 |
| 2013 |
\c ; $R0="[1.AAB];" |
| 2014 |
\c SectionEnd |
| 2015 |
|
| 2016 |
\\<b\\>Example (4):\\</b\\> |
| 2017 |
|
| 2018 |
\c Section |
| 2019 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{}" $R0 |
| 2020 |
\c ; $R0="[1.AAB];[3.BBB];" |
| 2021 |
\c SectionEnd |
| 2022 |
|
| 2023 |
\\<b\\>Example (5):\\</b\\> |
| 2024 |
|
| 2025 |
\c Section |
| 2026 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{*" $R0 |
| 2027 |
\c ; $R0="[1.AAB];[2.BAA];" |
| 2028 |
\c SectionEnd |
| 2029 |
|
| 2030 |
\\<b\\>Example (6):\\</b\\> |
| 2031 |
|
| 2032 |
\c Section |
| 2033 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "/2.BAA" $R0 |
| 2034 |
\c ; $R0="2" |
| 2035 |
\c SectionEnd |
| 2036 |
|
| 2037 |
\\<b\\>Example (With errorlevel output):\\</b\\> |
| 2038 |
|
| 2039 |
\c Section |
| 2040 |
\c ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "XX" "];" "E+1" $R0 |
| 2041 |
\c ; $R0="1" ("[...XX...];" not found) |
| 2042 |
\c |
| 2043 |
\c IfErrors 0 noerrors |
| 2044 |
\c MessageBox MB_OK 'Errorlevel=$R0' IDOK end |
| 2045 |
\c |
| 2046 |
\c noerrors: |
| 2047 |
\c MessageBox MB_OK 'No errors' |
| 2048 |
\c |
| 2049 |
\c end: |
| 2050 |
\c SectionEnd |
| 2051 |
|
| 2052 |
\S1{wordfind3xs} WordFind3XS |
| 2053 |
|
| 2054 |
\b Same as \R{wordfind3x}{WordFind3X}, but case sensitive. |
| 2055 |
|
| 2056 |
\S1{wordreplace} WordReplace |
| 2057 |
|
| 2058 |
\b Replace or delete word from string. |
| 2059 |
|
| 2060 |
\\<b\\>Syntax:\\</b\\> |
| 2061 |
|
| 2062 |
\c ${WordReplace} "[string]" "[word1]" "[word2]" "[E][options]" $var |
| 2063 |
|
| 2064 |
\c "[string]" ;[string] |
| 2065 |
\c ; input string |
| 2066 |
\c "[word1]" ;[word1] |
| 2067 |
\c ; word to replace or delete |
| 2068 |
\c "[word2]" ;[word2] |
| 2069 |
\c ; replace with (if empty delete) |
| 2070 |
\c "[E][options]" ;[options] |
| 2071 |
\c ; +number : word number from start |
| 2072 |
\c ; -number : word number from end |
| 2073 |
\c ; +number* : word number from start multiple-replace |
| 2074 |
\c ; -number* : word number from end multiple-replace |
| 2075 |
\c ; + : replace all results |
| 2076 |
\c ; +* : multiple-replace all results |
| 2077 |
\c ; { : if exists replace all delimiters |
| 2078 |
\c ; from left edge |
| 2079 |
\c ; } : if exists replace all delimiters |
| 2080 |
\c ; from right edge |
| 2081 |
\c ; {} : if exists replace all delimiters |
| 2082 |
\c ; from edges |
| 2083 |
\c ; {* : if exists multiple-replace all |
| 2084 |
\c ; delimiters from left edge |
| 2085 |
\c ; }* : if exists multiple-replace all |
| 2086 |
\c ; delimiters from right edge |
| 2087 |
\c ; {}* : if exists multiple-replace all |
| 2088 |
\c ; delimiters from edges |
| 2089 |
\c ; |
| 2090 |
\c ;[E] |
| 2091 |
\c ; with errorlevel output |
| 2092 |
\c ; IfErrors: |
| 2093 |
\c ; $var=1 word to replace not found |
| 2094 |
\c ; $var=2 no such word number |
| 2095 |
\c ; $var=3 syntax error (Use: +1,-1,+1*,-1*,+,+*,{},{}*) |
| 2096 |
\c ;[] |
| 2097 |
\c ; no errorlevel output (default) |
| 2098 |
\c ; If some errors found then (result=input string) |
| 2099 |
\c ; |
| 2100 |
\c $var ;output (result) |
| 2101 |
|
| 2102 |
\\<b\\>Example (replace):\\</b\\> |
| 2103 |
|
| 2104 |
\c Section |
| 2105 |
\c ${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" "SYS" "bmp" "+2" $R0 |
| 2106 |
\c ; $R0="C:\io.sys C:\logo.bmp C:\WINDOWS" |
| 2107 |
\c SectionEnd |
| 2108 |
|
| 2109 |
\\<b\\>Example (delete):\\</b\\> |
| 2110 |
|
| 2111 |
\c Section |
| 2112 |
\c ${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" "SYS" "" "+" $R0 |
| 2113 |
\c ; $R0="C:\io. C:\logo. C:\WINDOWS" |
| 2114 |
\c SectionEnd |
| 2115 |
|
| 2116 |
\\<b\\>Example (multiple-replace 1):\\</b\\> |
| 2117 |
|
| 2118 |
\c Section |
| 2119 |
\c ${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" " " " " "+1*" $R0 |
| 2120 |
\c ; +1* or +2* or +3* or +4* or +5* or +6* |
| 2121 |
\c ; $R0="C:\io.sys C:\logo.sys C:\WINDOWS" |
| 2122 |
\c SectionEnd |
| 2123 |
|
| 2124 |
\\<b\\>Example (multiple-replace 2):\\</b\\> |
| 2125 |
|
| 2126 |
\c Section |
| 2127 |
\c ${WordReplace} "C:\io.sys C:\logo.sysSYSsys C:\WINDOWS" "sys" "bmp" "+*" $R0 |
| 2128 |
\c ; $R0="C:\io.bmp C:\logo.bmp C:\WINDOWS" |
| 2129 |
\c SectionEnd |
| 2130 |
|
| 2131 |
\\<b\\>Example (multiple-replace 3):\\</b\\> |
| 2132 |
|
| 2133 |
\c Section |
| 2134 |
\c ${WordReplace} "sysSYSsysC:\io.sys C:\logo.sys C:\WINDOWSsysSYSsys" "sys" "|" "{}*" $R0 |
| 2135 |
\c ; $R0="|C:\io.sys C:\logo.sys C:\WINDOWS|" |
| 2136 |
\c SectionEnd |
| 2137 |
|
| 2138 |
\\<b\\>Example (With errorlevel output):\\</b\\> |
| 2139 |
|
| 2140 |
\c Section |
| 2141 |
\c ${WordReplace} "C:\io.sys C:\logo.sys" "sys" "bmp" "E+3" $R0 |
| 2142 |
\c ; $R0="2" (no such word number "+3") |
| 2143 |
\c |
| 2144 |
\c IfErrors 0 noerrors |
| 2145 |
\c MessageBox MB_OK 'Errorlevel=$R0' IDOK end |
| 2146 |
\c |
| 2147 |
\c noerrors: |
| 2148 |
\c MessageBox MB_OK 'No errors' |
| 2149 |
\c |
| 2150 |
\c end: |
| 2151 |
\c SectionEnd |
| 2152 |
|
| 2153 |
\S1{wordreplaces} WordReplaceS |
| 2154 |
|
| 2155 |
\b Same as \R{wordreplace}{WordReplace}, but case sensitive. |
| 2156 |
|
| 2157 |
\S1{wordadd} WordAdd |
| 2158 |
|
| 2159 |
\b Add words to string1 from string2 if not exist or delete words if exist. |
| 2160 |
|
| 2161 |
\\<b\\>Syntax:\\</b\\> |
| 2162 |
|
| 2163 |
\c ${WordAdd} "[string1]" "[delimiter]" "[E][options]" $var |
| 2164 |
|
| 2165 |
\c "[string1]" ;[string1] |
| 2166 |
\c ; string for addition or removing |
| 2167 |
\c "[delimiter]" ;[delimiter] |
| 2168 |
\c ; one or several symbols |
| 2169 |
\c "[E][options]" ;[options] |
| 2170 |
\c ; +string2 : words to add |
| 2171 |
\c ; -string2 : words to delete |
| 2172 |
\c ; |
| 2173 |
\c ;[E] |
| 2174 |
\c ; with errorlevel output |
| 2175 |
\c ; IfErrors: |
| 2176 |
\c ; $var=1 delimiter is empty |
| 2177 |
\c ; $var=3 syntax error (use: +text,-text) |
| 2178 |
\c ;[] |
| 2179 |
\c ; no errorlevel output (default) |
| 2180 |
\c ; If some errors found then (result=input string) |
| 2181 |
\c ; |
| 2182 |
\c $var ;output (result) |
| 2183 |
|
| 2184 |
\\<b\\>Example (add):\\</b\\> |
| 2185 |
|
| 2186 |
\c Section |
| 2187 |
\c ${WordAdd} "C:\io.sys C:\WINDOWS" " " "+C:\WINDOWS C:\config.sys" $R0 |
| 2188 |
\c ; $R0="C:\io.sys C:\WINDOWS C:\config.sys" |
| 2189 |
\c SectionEnd |
| 2190 |
|
| 2191 |
\\<b\\>Example (delete):\\</b\\> |
| 2192 |
|
| 2193 |
\c Section |
| 2194 |
\c ${WordAdd} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "-C:\WINDOWS C:\config.sys C:\IO.SYS" $R0 |
| 2195 |
\c ; $R0="C:\logo.sys" |
| 2196 |
\c SectionEnd |
| 2197 |
|
| 2198 |
\\<b\\>Example (add to one):\\</b\\> |
| 2199 |
|
| 2200 |
\c Section |
| 2201 |
\c ${WordAdd} "C:\io.sys" " " "+C:\WINDOWS C:\config.sys C:\IO.SYS" $R0 |
| 2202 |
\c ; $R0="C:\io.sys C:\WINDOWS C:\config.sys" |
| 2203 |
\c SectionEnd |
| 2204 |
|
| 2205 |
\\<b\\>Example (delete one):\\</b\\> |
| 2206 |
|
| 2207 |
\c Section |
| 2208 |
\c ${WordAdd} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "-C:\WINDOWS" $R0 |
| 2209 |
\c ; $R0="C:\io.sys C:\logo.sys" |
| 2210 |
\c SectionEnd |
| 2211 |
|
| 2212 |
\\<b\\>Example (No new words found):\\</b\\> |
| 2213 |
|
| 2214 |
\c Section |
| 2215 |
\c ${WordAdd} "C:\io.sys C:\logo.sys" " " "+C:\logo.sys" $R0 |
| 2216 |
\c StrCmp $R0 "C:\io.sys C:\logo.sys" 0 +2 |
| 2217 |
\c MessageBox MB_OK "No new words found to add" |
| 2218 |
\c SectionEnd |
| 2219 |
|
| 2220 |
\\<b\\>Example (No words deleted):\\</b\\> |
| 2221 |
|
| 2222 |
\c Section |
| 2223 |
\c ${WordAdd} "C:\io.sys C:\logo.sys" " " "-C:\config.sys" $R0 |
| 2224 |
\c StrCmp $R0 "C:\io.sys C:\logo.sys" 0 +2 |
| 2225 |
\c MessageBox MB_OK "No words found to delete" |
| 2226 |
\c SectionEnd |
| 2227 |
|
| 2228 |
\\<b\\>Example (With errorlevel output):\\</b\\> |
| 2229 |
|
| 2230 |
\c Section |
| 2231 |
\c ${WordAdd} "C:\io.sys C:\logo.sys" "" "E-C:\logo.sys" $R0 |
| 2232 |
\c ; $R0="1" (delimiter is empty "") |
| 2233 |
\c |
| 2234 |
\c IfErrors 0 noerrors |
| 2235 |
\c MessageBox MB_OK 'Errorlevel=$R0' IDOK end |
| 2236 |
\c |
| 2237 |
\c noerrors: |
| 2238 |
\c MessageBox MB_OK 'No errors' |
| 2239 |
\c |
| 2240 |
\c end: |
| 2241 |
\c SectionEnd |
| 2242 |
|
| 2243 |
\S1{wordadds} WordAddS |
| 2244 |
|
| 2245 |
\b Same as \R{wordadd}{WordAdd}, but case sensitive. |
| 2246 |
|
| 2247 |
\S1{wordinsert} WordInsert |
| 2248 |
|
| 2249 |
\b Insert word in string. |
| 2250 |
|
| 2251 |
\\<b\\>Syntax:\\</b\\> |
| 2252 |
|
| 2253 |
\c ${WordInsert} "[string]" "[delimiter]" "[word]" "[E][options]" $var |
| 2254 |
|
| 2255 |
\c "[string]" ;[string] |
| 2256 |
\c ; input string |
| 2257 |
\c "[delimiter]" ;[delimiter] |
| 2258 |
\c ; one or several symbols |
| 2259 |
\c "[word]" ;[word] |
| 2260 |
\c ; word to insert |
| 2261 |
\c "[E][options]" ;[options] |
| 2262 |
\c ; +number : word number from start |
| 2263 |
\c ; -number : word number from end |
| 2264 |
\c ; |
| 2265 |
\c ;[E] |
| 2266 |
\c ; with errorlevel output |
| 2267 |
\c ; IfErrors: |
| 2268 |
\c ; $var=1 delimiter is empty |
| 2269 |
\c ; $var=2 wrong word number |
| 2270 |
\c ; $var=3 syntax error (Use: +1,-1) |
| 2271 |
\c ;[] |
| 2272 |
\c ; no errorlevel output (default) |
| 2273 |
\c ; If some errors found then (result=input string) |
| 2274 |
\c ; |
| 2275 |
\c $var ;output (result) |
| 2276 |
|
| 2277 |
\\<b\\>Example (1):\\</b\\> |
| 2278 |
|
| 2279 |
\c Section |
| 2280 |
\c ${WordInsert} "C:\io.sys C:\WINDOWS" " " "C:\logo.sys" "-2" $R0 |
| 2281 |
\c ; $R0="C:\io.sys C:\logo.sys C:\WINDOWS" |
| 2282 |
\c SectionEnd |
| 2283 |
|
| 2284 |
\\<b\\>Example (2):\\</b\\> |
| 2285 |
|
| 2286 |
\c Section |
| 2287 |
\c ${WordInsert} "C:\io.sys" " " "C:\WINDOWS" "+2" $R0 |
| 2288 |
\c ; $R0="C:\io.sys C:\WINDOWS" |
| 2289 |
\c SectionEnd |
| 2290 |
|
| 2291 |
\\<b\\>Example (3):\\</b\\> |
| 2292 |
|
| 2293 |
\c Section |
| 2294 |
\c ${WordInsert} "" " " "C:\WINDOWS" "+1" $R0 |
| 2295 |
\c ; $R0="C:\WINDOWS " |
| 2296 |
\c SectionEnd |
| 2297 |
|
| 2298 |
\\<b\\>Example (With errorlevel output):\\</b\\> |
| 2299 |
|
| 2300 |
\c Section |
| 2301 |
\c ${WordInsert} "C:\io.sys C:\logo.sys" " " "C:\logo.sys" "E+4" $R0 |
| 2302 |
\c ; $R0="2" (wrong word number "+4") |
| 2303 |
\c |
| 2304 |
\c IfErrors 0 noerrors |
| 2305 |
\c MessageBox MB_OK 'Errorlevel=$R0' IDOK end |
| 2306 |
\c |
| 2307 |
\c noerrors: |
| 2308 |
\c MessageBox MB_OK 'No errors' |
| 2309 |
\c |
| 2310 |
\c end: |
| 2311 |
\c SectionEnd |
| 2312 |
|
| 2313 |
\S1{wordinserts} WordInsertS |
| 2314 |
|
| 2315 |
\b Same as \R{wordinsert}{WordInsert}, but case sensitive. |
| 2316 |
|
| 2317 |
\S1{strfilter} StrFilter |
| 2318 |
|
| 2319 |
\b Convert string to uppercase or lowercase. |
| 2320 |
|
| 2321 |
\b Set symbol filter. |
| 2322 |
|
| 2323 |
\\<b\\>Syntax:\\</b\\> |
| 2324 |
|
| 2325 |
\c ${StrFilter} "[string]" "[options]" "[symbols1]" "[symbols2]" $var |
| 2326 |
|
| 2327 |
\c "[string]" ;[string] |
| 2328 |
\c ; input string |
| 2329 |
\c ; |
| 2330 |
\c "[options]" ;[+|-][1|2|3|12|23|31][eng|rus] |
| 2331 |
\c ; + : convert string to uppercase |
| 2332 |
\c ; - : convert string to lowercase |
| 2333 |
\c ; 1 : only Digits |
| 2334 |
\c ; 2 : only Letters |
| 2335 |
\c ; 3 : only Special |
| 2336 |
\c ; 12 : only Digits + Letters |
| 2337 |
\c ; 23 : only Letters + Special |
| 2338 |
\c ; 31 : only Special + Digits |
| 2339 |
\c ; eng : English symbols (default) |
| 2340 |
\c ; rus : Russian symbols |
| 2341 |
\c ; |
| 2342 |
\c "[symbols1]" ;[symbols1] |
| 2343 |
\c ; symbols include (not changeable) |
| 2344 |
\c ; |
| 2345 |
\c "[symbols2]" ;[symbols2] |
| 2346 |
\c ; symbols exclude |
| 2347 |
\c ; |
| 2348 |
\c $var ;output (result) |
| 2349 |
|
| 2350 |
\\<b\\>Note:\\</b\\> |
| 2351 |
\\<br\\>- Error flag if syntax error |
| 2352 |
\\<br\\>- Same symbol to include & to exclude = to exclude |
| 2353 |
|
| 2354 |
\\<b\\>Example (UpperCase):\\</b\\> |
| 2355 |
|
| 2356 |
\c Section |
| 2357 |
\c ${StrFilter} "123abc 456DEF 7890|%#" "+" "" "" $R0 |
| 2358 |
\c ; $R0="123ABC 456DEF 7890|%#" |
| 2359 |
\c SectionEnd |
| 2360 |
|
| 2361 |
\\<b\\>Example (LowerCase):\\</b\\> |
| 2362 |
|
| 2363 |
\c Section |
| 2364 |
\c ${StrFilter} "123abc 456DEF 7890|%#" "-" "ef" "" $R0 |
| 2365 |
\c ; $R0="123abc 456dEF 7890|%#" |
| 2366 |
\c SectionEnd |
| 2367 |
|
| 2368 |
\\<b\\>Example (Filter1):\\</b\\> |
| 2369 |
|
| 2370 |
\c Section |
| 2371 |
\c ${StrFilter} "123abc 456DEF 7890|%#" "2" "|%" "" $R0 |
| 2372 |
\c ; $R0="abcDEF|%" ;only Letters + |% |
| 2373 |
\c SectionEnd |
| 2374 |
|
| 2375 |
\\<b\\>Example (Filter2):\\</b\\> |
| 2376 |
|
| 2377 |
\c Section |
| 2378 |
\c ${StrFilter} "123abc 456DEF 7890|%#" "13" "af" "4590" $R0 |
| 2379 |
\c ; $R0="123a 6F 78|%#" ;only Digits + Special + af - 4590 |
| 2380 |
\c SectionEnd |
| 2381 |
|
| 2382 |
\\<b\\>Example (Filter3):\\</b\\> |
| 2383 |
|
| 2384 |
\c Section |
| 2385 |
\c ${StrFilter} "123abc 456DEF 7890|%#" "+12" "b" "def" $R0 |
| 2386 |
\c ; $R0="123AbC4567890" ;only Digits + Letters + b - def |
| 2387 |
\c SectionEnd |
| 2388 |
|
| 2389 |
\\<b\\>Example (Filter4):\\</b\\> |
| 2390 |
|
| 2391 |
\c Section |
| 2392 |
\c ${StrFilter} "123abcְֱֲ 456DEFדהו 7890|%#" "+12rus" "ה" "דו" $R0 |
| 2393 |
\c ; $R0="123ְֱֲ456ה7890" ;only Digits + Letters + ה - דו |
| 2394 |
\c SectionEnd |
| 2395 |
|
| 2396 |
\\<b\\>Example (English + Russian Letters):\\</b\\> |
| 2397 |
|
| 2398 |
\c Section |
| 2399 |
\c ${StrFilter} "123abcְֱֲ 456DEFדהו 7890|%#" "2rus" "" "" $R0 |
| 2400 |
\c ; $R0="ְֱֲדהו" ;only Russian Letters |
| 2401 |
\c ${StrFilter} "123abcְֱֲ 456DEFדהו 7890|%#" "2" "$R0" "" $R0 |
| 2402 |
\c ; $R0="abcְֱֲDEFדהו" ;only English + Russian Letters |
| 2403 |
\c SectionEnd |
| 2404 |
|
| 2405 |
\\<b\\>Example (Word Capitalize):\\</b\\> |
| 2406 |
|
| 2407 |
\c Section |
| 2408 |
\c Push "_01-PERPETUOUS_DREAMER__-__THE_SOUND_OF_GOODBYE_(ORIG._MIX).MP3_" |
| 2409 |
\c Call Capitalize |
| 2410 |
\c Pop $R0 |
| 2411 |
\c ; $R0="_01-Perpetuous_Dreamer__-__The_Sound_Of_Goodbye_(Orig._Mix).mp3_" |
| 2412 |
\c |
| 2413 |
\c ${WordReplace} "$R0" "_" " " "+*" $R0 |
| 2414 |
\c ; $R0=" 01-Perpetuous Dreamer - The Sound Of Goodbye (Orig. Mix).mp3 " |
| 2415 |
\c |
| 2416 |
\c ${WordReplace} "$R0" " " "" "{}" $R0 |
| 2417 |
\c ; $R0="01-Perpetuous Dreamer - The Sound Of Goodbye (Orig. Mix).mp3" |
| 2418 |
\c SectionEnd |
| 2419 |
\c |
| 2420 |
\c Function Capitalize |
| 2421 |
\c Exch $R0 |
| 2422 |
\c Push $0 |
| 2423 |
\c Push $1 |
| 2424 |
\c Push $2 |
| 2425 |
\c |
| 2426 |
\c ${StrFilter} '$R0' '-eng' '' '' $R0 |
| 2427 |
\c ${StrFilter} '$R0' '-rus' '' '' $R0 |
| 2428 |
\c |
| 2429 |
\c StrCpy $0 0 |
| 2430 |
\c |
| 2431 |
\c loop: |
| 2432 |
\c IntOp $0 $0 + 1 |
| 2433 |
\c StrCpy $1 $R0 1 $0 |
| 2434 |
\c StrCmp $1 '' end |
| 2435 |
\c StrCmp $1 ' ' +5 |
| 2436 |
\c StrCmp $1 '_' +4 |
| 2437 |
\c StrCmp $1 '-' +3 |
| 2438 |
\c StrCmp $1 '(' +2 |
| 2439 |
\c StrCmp $1 '[' 0 loop |
| 2440 |
\c IntOp $0 $0 + 1 |
| 2441 |
\c StrCpy $1 $R0 1 $0 |
| 2442 |
\c StrCmp $1 '' end |
| 2443 |
\c |
| 2444 |
\c ${StrFilter} '$1' '+eng' '' '' $1 |
| 2445 |
\c ${StrFilter} '$1' '+rus' '' '' $1 |
| 2446 |
\c |
| 2447 |
\c StrCpy $2 $R0 $0 |
| 2448 |
\c IntOp $0 $0 + 1 |
| 2449 |
\c StrCpy $R0 $R0 '' $0 |
| 2450 |
\c IntOp $0 $0 - 2 |
| 2451 |
\c StrCpy $R0 '$2$1$R0' |
| 2452 |
\c goto loop |
| 2453 |
\c |
| 2454 |
\c end: |
| 2455 |
\c Pop $2 |
| 2456 |
\c Pop $1 |
| 2457 |
\c Pop $0 |
| 2458 |
\c Exch $R0 |
| 2459 |
\c FunctionEnd |
| 2460 |
|
| 2461 |
\S1{strfilters} StrFilterS |
| 2462 |
|
| 2463 |
\b Same as \R{strfilter}{StrFilter}, but case sensitive. |
| 2464 |
|
| 2465 |
\S1{versioncompare} VersionCompare |
| 2466 |
|
| 2467 |
\b Compare version numbers. |
| 2468 |
|
| 2469 |
\\<b\\>Syntax:\\</b\\> |
| 2470 |
|
| 2471 |
\c ${VersionCompare} "[Version1]" "[Version2]" $var |
| 2472 |
|
| 2473 |
\c "[Version1]" ; First version |
| 2474 |
\c "[Version2]" ; Second version |
| 2475 |
\c $var ; Result: |
| 2476 |
\c ; $var=0 Versions are equal |
| 2477 |
\c ; $var=1 Version1 is newer |
| 2478 |
\c ; $var=2 Version2 is newer |
| 2479 |
|
| 2480 |
\\<b\\>Example:\\</b\\> |
| 2481 |
|
| 2482 |
\c Section |
| 2483 |
\c ${VersionCompare} "1.1.1.9" "1.1.1.01" $R0 |
| 2484 |
\c ; $R0="1" |
| 2485 |
\c SectionEnd |
| 2486 |
|
| 2487 |
\S1{versionconvert} VersionConvert |
| 2488 |
|
| 2489 |
\b Convert version in the numerical format which can be compared. |
| 2490 |
|
| 2491 |
\\<b\\>Syntax:\\</b\\> |
| 2492 |
|
| 2493 |
\c ${VersionConvert} "[Version]" "[CharList]" $var |
| 2494 |
|
| 2495 |
\c "[Version]" ; Version |
| 2496 |
\c ; |
| 2497 |
\c "[CharList]" ; List of characters, which will be replaced by numbers |
| 2498 |
\c ; "abcdefghijklmnopqrstuvwxyz" (default) |
| 2499 |
\c ; |
| 2500 |
\c $var ; Result: converted version |
| 2501 |
|
| 2502 |
\\<b\\>Note:\\</b\\> |
| 2503 |
\\<br\\>- Converted letters are separated with dot |
| 2504 |
\\<br\\>- If character is non-digit and not in list then it will be converted to dot |
| 2505 |
|
| 2506 |
\\<b\\>Example1:\\</b\\> |
| 2507 |
|
| 2508 |
\c Section |
| 2509 |
\c ${VersionConvert} "9.0a" "" $R0 |
| 2510 |
\c ; $R0="9.0.01" |
| 2511 |
\c |
| 2512 |
\c ${VersionConvert} "9.0c" "" $R1 |
| 2513 |
\c ; $R1="9.0.03" |
| 2514 |
\c |
| 2515 |
\c ${VersionCompare} "$R0" "$R1" $R2 |
| 2516 |
\c ; $R2="2" version2 is newer |
| 2517 |
\c SectionEnd |
| 2518 |
|
| 2519 |
\\<b\\>Example2:\\</b\\> |
| 2520 |
|
| 2521 |
\c Section |
| 2522 |
\c ${VersionConvert} "0.15c-9m" "" $R0 |
| 2523 |
\c ; $R0="0.15.03.9.13" |
| 2524 |
\c |
| 2525 |
\c ${VersionConvert} "0.15c-1n" "" $R1 |
| 2526 |
\c ; $R1="0.15.03.1.14" |
| 2527 |
\c |
| 2528 |
\c ${VersionCompare} "$R0" "$R1" $R2 |
| 2529 |
\c ; $R2="1" version1 is newer |
| 2530 |
\c SectionEnd |
| 2531 |
|
| 2532 |
\\<b\\>Example3:\\</b\\> |
| 2533 |
|
| 2534 |
\c Section |
| 2535 |
\c ${VersionConvert} "0.15c+" "abcdefghijklmnopqrstuvwxyz+" $R0 |
| 2536 |
\c ; $R0="0.15.0327" |
| 2537 |
\c |
| 2538 |
\c ${VersionConvert} "0.15c" "abcdefghijklmnopqrstuvwxyz+" $R1 |
| 2539 |
\c ; $R1="0.15.03" |
| 2540 |
\c |
| 2541 |
\c ${VersionCompare} "$R0" "$R1" $R2 |
| 2542 |
\c ; $R2="1" version1 is newer |
| 2543 |
\c SectionEnd |