E.3 Word Functions Header

E.3.1 Introduction

Include header:

  1. !include "WordFunc.nsh"

Call functions:

  1. Section Install
  2. ${WordFind} "A--H---S" "-" "+2" $R0
  3. ; $R0="H"
  4. SectionEnd
  1. Section un.Install
  2. ${WordReplace} "A--H---S" "-" "x" "+3*" $R0
  3. ; $R0="A--HxS"
  4. SectionEnd

E.3.2 WordFind

  • Multi-features string function.
  1. Strings:
  2. "[word+1][delimiter][word+2][delimiter][word+3]..."
  3. "[delimiter][word+1][delimiter][word+2][delimiter]..."
  4. "[delimiter][delimiter][word+1][delimiter][delimiter][delimiter]..."
  5. "...[word-3][delimiter][word-2][delimiter][word-1]"
  6. "...[delimiter][word-2][delimiter][word-1][delimiter]"
  7. "...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]"

Syntax:

  1. ${WordFind} "[string]" "[delimiter]" "[E][options]" $var
  1. "[string]" ;[string]
  2. ; input string
  3. "[delimiter]" ;[delimiter]
  4. ; one or several symbols
  5. "[E][options]" ;[options]
  6. ; +number : word number from start
  7. ; -number : word number from end
  8. ; +number} : delimiter number from start
  9. ; all space after this
  10. ; delimiter to output
  11. ; +number{ : delimiter number from start
  12. ; all space before this
  13. ; delimiter to output
  14. ; +number}} : word number from start
  15. ; all space after this word
  16. ; to output
  17. ; +number{{ : word number from start
  18. ; all space before this word
  19. ; to output
  20. ; +number{} : word number from start
  21. ; all space before and after
  22. ; this word (word exclude)
  23. ; +number*} : word number from start
  24. ; all space after this
  25. ; word to output with word
  26. ; +number{* : word number from start
  27. ; all space before this
  28. ; word to output with word
  29. ; # : sum of words to output
  30. ; * : sum of delimiters to output
  31. ; /word : number of word to output
  32. ;
  33. ;[E]
  34. ; with errorlevel output
  35. ; IfErrors:
  36. ; $var=1 delimiter not found
  37. ; $var=2 no such word number
  38. ; $var=3 syntax error (Use: +1,-1},#,*,/word,...)
  39. ;[]
  40. ; no errorlevel output (default)
  41. ; If some errors found then (result=input string)
  42. ;
  43. $var ;output (result)

Note:- Accepted numbers 1,01,001,…

Example (Find word by number):

  1. Section
  2. ${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " C:\" "-02" $R0
  3. ; $R0="Program Files"
  4. SectionEnd

Example (Delimiter exclude):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "-2}" $R0
  3. ; $R0=" C:\logo.sys C:\WINDOWS"
  4. SectionEnd

Example (Sum of words):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $R0
  3. ; $R0="3"
  4. SectionEnd

Example (Sum of delimiters):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0
  3. ; $R0="2"
  4. SectionEnd

Example (Find word number):

  1. Section
  2. ${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " " "/Files" $R0
  3. ; $R0="3"
  4. SectionEnd

Example ( }} ):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2}}" $R0
  3. ; $R0=" C:\WINDOWS"
  4. SectionEnd

Example ( {} ):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2{}" $R0
  3. ; $R0="C:\io.sys C:\WINDOWS"
  4. SectionEnd

Example ( *} ):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2*}" $R0
  3. ; $R0="C:\logo.sys C:\WINDOWS"
  4. SectionEnd

Example (Get parent directory):

  1. Section
  2. StrCpy $R0 "C:\Program Files\NSIS\NSIS.chm"
  3. ; "C:\Program Files\NSIS\Include\"
  4. ; "C:\\Program Files\\NSIS\\NSIS.chm"
  5.  
  6. ${WordFind} "$R0" "\" "-2{*" $R0
  7. ; $R0="C:\Program Files\NSIS"
  8. ; "C:\\Program Files\\NSIS"
  9. SectionEnd

Example (Coordinates):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" ":\lo" "E+1{" $R0
  3. ; $R0="C:\io.sys C"
  4. IfErrors end
  5.  
  6. StrLen $0 $R0 ; $0 = Start position of word (11)
  7. StrLen $1 ':\lo' ; $1 = Word length (4)
  8. ; StrCpy $R0 $R1 $1 $0 ; $R0 = :\lo
  9.  
  10. end:
  11. SectionEnd

Example (With errorlevel output):

  1. Section
  2. ${WordFind} "[string]" "[delimiter]" "E[options]" $R0
  3.  
  4. IfErrors 0 end
  5. StrCmp $R0 1 0 +2 ; errorlevel 1?
  6. MessageBox MB_OK 'delimiter not found' IDOK end
  7. StrCmp $R0 2 0 +2 ; errorlevel 2?
  8. MessageBox MB_OK 'no such word number' IDOK end
  9. StrCmp $R0 3 0 +2 ; errorlevel 3?
  10. MessageBox MB_OK 'syntax error'
  11.  
  12. end:
  13. SectionEnd

Example (Without errorlevel output):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys" "_" "+1" $R0
  3.  
  4. ; $R0="C:\io.sys C:\logo.sys" (error: delimiter "_" not found)
  5. SectionEnd

Example (If found):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "E+1{" $R0
  3.  
  4. IfErrors notfound found
  5. found:
  6. MessageBox MB_OK 'Found' IDOK end
  7. notfound:
  8. MessageBox MB_OK 'Not found'
  9.  
  10. end:
  11. SectionEnd

Example (If found 2):

  1. Section
  2. ${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "+1{" $R0
  3.  
  4. StrCmp $R0 "C:\io.sys C:\logo.sys" notfound found ; error?
  5. found:
  6. MessageBox MB_OK 'Found' IDOK end
  7. notfound:
  8. MessageBox MB_OK 'Not found'
  9.  
  10. end:
  11. SectionEnd

Example (To accept one word in string if delimiter not found):

  1. Section
  2. StrCpy $0 'OneWord'
  3. StrCpy $1 1
  4.  
  5. loop:
  6. ${WordFind} "$0" " " "E+$1" $R0
  7. IfErrors 0 code
  8. StrCmp $1$R0 11 0 error
  9. StrCpy $R0 $0
  10. goto end
  11.  
  12. code:
  13. ; ...
  14. IntOp $1 $1 + 1
  15. goto loop
  16.  
  17. error:
  18. StrCpy $1 ''
  19. StrCpy $R0 ''
  20.  
  21. end:
  22. ; $R0="OneWord"
  23. SectionEnd

E.3.3 WordFindS

E.3.4 WordFind2X

  • Find word between two delimiters.
  1. Strings:
  2. "[delimiter1][word+1][delimiter2][delimiter1][word+2][delimiter2]..."
  3. "[text][delimiter1][text][delimiter1][word+1][delimiter2][text]..."
  4. "...[delimiter1][word-2][delimiter2][delimiter1][word-1][delimiter2]"
  5. "...[text][delimiter1][text][delimiter1][word-1][delimiter2][text]"

Syntax:

  1. ${WordFind2X} "[string]" "[delimiter1]" "[delimiter2]" "[E][options]" $var
  1. "[string]" ;[string]
  2. ; input string
  3. "[delimiter1]" ;[delimiter1]
  4. ; first delimiter
  5. "[delimiter2]" ;[delimiter2]
  6. ; second delimiter
  7. "[E][options]" ;[options]
  8. ; +number : word number from start
  9. ; -number : word number from end
  10. ; +number}} : word number from start all space
  11. ; after this word to output
  12. ; +number{{ : word number from end all space
  13. ; before this word to output
  14. ; +number{} : word number from start
  15. ; all space before and after
  16. ; this word (word exclude)
  17. ; +number*} : word number from start
  18. ; all space after this
  19. ; word to output with word
  20. ; +number{* : word number from start
  21. ; all space before this
  22. ; word to output with word
  23. ; # : sum of words to output
  24. ; /word : number of word to output
  25. ;
  26. ;[E]
  27. ; with errorlevel output
  28. ; IfErrors:
  29. ; $var=1 no words found
  30. ; $var=2 no such word number
  31. ; $var=3 syntax error (Use: +1,-1,#)
  32. ;[]
  33. ; no errorlevel output (default)
  34. ; If some errors found then (result=input string)
  35. ;
  36. $var ;output (result)

Example (1):

  1. Section
  2. ${WordFind2X} "[C:\io.sys];[C:\logo.sys];[C:\WINDOWS]" "[C:\" "];" "+2" $R0
  3. ; $R0="logo.sys"
  4. SectionEnd

Example (2):

  1. Section
  2. ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1" $R0
  3. ; $R0="logo"
  4. SectionEnd

Example (3):

  1. Section
  2. ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{{" $R0
  3. ; $R0="C:\WINDOWS C:\io.sys C:"
  4. SectionEnd

Example (4):

  1. Section
  2. ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{}" $R0
  3. ; $R0="C:\WINDOWS C:\io.sys C:sys"
  4. SectionEnd

Example (5):

  1. Section
  2. ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "-1{*" $R0
  3. ; $R0="C:\WINDOWS C:\io.sys C:\logo."
  4. SectionEnd

Example (6):

  1. Section
  2. ${WordFind2X} "C:\WINDOWS C:\io.sys C:\logo.sys" "\" "." "/logo" $R0
  3. ; $R0="2"
  4. SectionEnd

Example (With errorlevel output):

  1. Section
  2. ${WordFind2X} "[io.sys];[C:\logo.sys]" "\" "];" "E+1" $R0
  3. ; $R0="1" ("\...];" not found)
  4.  
  5. IfErrors 0 noerrors
  6. MessageBox MB_OK 'Errorlevel=$R0' IDOK end
  7.  
  8. noerrors:
  9. MessageBox MB_OK 'No errors'
  10.  
  11. end:
  12. SectionEnd

E.3.5 WordFind2XS

E.3.6 WordFind3X

  • Find a word that contains a string, between two delimiters.

Syntax:

  1. ${WordFind3X} "[string]" "[delimiter1]" "[center]" "[delimiter2]" "[E][options]" $var
  1. "[string]" ;[string]
  2. ; input string
  3. "[delimiter1]" ;[delimiter1]
  4. ; first delimiter
  5. "[center]" ;[center]
  6. ; center string
  7. "[delimiter2]" ;[delimiter2]
  8. ; second delimiter
  9. "[E][options]" ;[options]
  10. ; +number : word number from start
  11. ; -number : word number from end
  12. ; +number}} : word number from start all space
  13. ; after this word to output
  14. ; +number{{ : word number from end all space
  15. ; before this word to output
  16. ; +number{} : word number from start
  17. ; all space before and after
  18. ; this word (word exclude)
  19. ; +number*} : word number from start
  20. ; all space after this
  21. ; word to output with word
  22. ; +number{* : word number from start
  23. ; all space before this
  24. ; word to output with word
  25. ; # : sum of words to output
  26. ; /word : number of word to output
  27. ;
  28. ;[E]
  29. ; with errorlevel output
  30. ; IfErrors:
  31. ; $var=1 no words found
  32. ; $var=2 no such word number
  33. ; $var=3 syntax error (Use: +1,-1,#)
  34. ;[]
  35. ; no errorlevel output (default)
  36. ; If some errors found then (result=input string)
  37. ;
  38. $var ;output (result)

Example (1):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "+1" $R0
  3. ; $R0="1.AAB"
  4. SectionEnd

Example (2):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1" $R0
  3. ; $R0="2.BAA"
  4. SectionEnd

Example (3):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{{" $R0
  3. ; $R0="[1.AAB];"
  4. SectionEnd

Example (4):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{}" $R0
  3. ; $R0="[1.AAB];[3.BBB];"
  4. SectionEnd

Example (5):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "-1{*" $R0
  3. ; $R0="[1.AAB];[2.BAA];"
  4. SectionEnd

Example (6):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "AA" "];" "/2.BAA" $R0
  3. ; $R0="2"
  4. SectionEnd

Example (With errorlevel output):

  1. Section
  2. ${WordFind3X} "[1.AAB];[2.BAA];[3.BBB];" "[" "XX" "];" "E+1" $R0
  3. ; $R0="1" ("[...XX...];" not found)
  4.  
  5. IfErrors 0 noerrors
  6. MessageBox MB_OK 'Errorlevel=$R0' IDOK end
  7.  
  8. noerrors:
  9. MessageBox MB_OK 'No errors'
  10.  
  11. end:
  12. SectionEnd

E.3.7 WordFind3XS

E.3.8 WordReplace

  • Replace or delete word from string.

Syntax:

  1. ${WordReplace} "[string]" "[word1]" "[word2]" "[E][options]" $var
  1. "[string]" ;[string]
  2. ; input string
  3. "[word1]" ;[word1]
  4. ; word to replace or delete
  5. "[word2]" ;[word2]
  6. ; replace with (if empty delete)
  7. "[E][options]" ;[options]
  8. ; +number : word number from start
  9. ; -number : word number from end
  10. ; +number* : word number from start multiple-replace
  11. ; -number* : word number from end multiple-replace
  12. ; + : replace all results
  13. ; +* : multiple-replace all results
  14. ; { : if exists replace all delimiters
  15. ; from left edge
  16. ; } : if exists replace all delimiters
  17. ; from right edge
  18. ; {} : if exists replace all delimiters
  19. ; from edges
  20. ; {* : if exists multiple-replace all
  21. ; delimiters from left edge
  22. ; }* : if exists multiple-replace all
  23. ; delimiters from right edge
  24. ; {}* : if exists multiple-replace all
  25. ; delimiters from edges
  26. ;
  27. ;[E]
  28. ; with errorlevel output
  29. ; IfErrors:
  30. ; $var=1 word to replace not found
  31. ; $var=2 no such word number
  32. ; $var=3 syntax error (Use: +1,-1,+1*,-1*,+,+*,{},{}*)
  33. ;[]
  34. ; no errorlevel output (default)
  35. ; If some errors found then (result=input string)
  36. ;
  37. $var ;output (result)

Example (replace):

  1. Section
  2. ${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" "SYS" "bmp" "+2" $R0
  3. ; $R0="C:\io.sys C:\logo.bmp C:\WINDOWS"
  4. SectionEnd

Example (delete):

  1. Section
  2. ${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" "SYS" "" "+" $R0
  3. ; $R0="C:\io. C:\logo. C:\WINDOWS"
  4. SectionEnd

Example (multiple-replace 1):

  1. Section
  2. ${WordReplace} "C:\io.sys C:\logo.sys C:\WINDOWS" " " " " "+1*" $R0
  3. ; +1* or +2* or +3* or +4* or +5* or +6*
  4. ; $R0="C:\io.sys C:\logo.sys C:\WINDOWS"
  5. SectionEnd

Example (multiple-replace 2):

  1. Section
  2. ${WordReplace} "C:\io.sys C:\logo.sysSYSsys C:\WINDOWS" "sys" "bmp" "+*" $R0
  3. ; $R0="C:\io.bmp C:\logo.bmp C:\WINDOWS"
  4. SectionEnd

Example (multiple-replace 3):

  1. Section
  2. ${WordReplace} "sysSYSsysC:\io.sys C:\logo.sys C:\WINDOWSsysSYSsys" "sys" "|" "{}*" $R0
  3. ; $R0="|C:\io.sys C:\logo.sys C:\WINDOWS|"
  4. SectionEnd

Example (With errorlevel output):

  1. Section
  2. ${WordReplace} "C:\io.sys C:\logo.sys" "sys" "bmp" "E+3" $R0
  3. ; $R0="2" (no such word number "+3")
  4.  
  5. IfErrors 0 noerrors
  6. MessageBox MB_OK 'Errorlevel=$R0' IDOK end
  7.  
  8. noerrors:
  9. MessageBox MB_OK 'No errors'
  10.  
  11. end:
  12. SectionEnd

E.3.9 WordReplaceS

E.3.10 WordAdd

  • Add words to string1 from string2 if not exist or delete words if exist.

Syntax:

  1. ${WordAdd} "[string1]" "[delimiter]" "[E][options]" $var
  1. "[string1]" ;[string1]
  2. ; string for addition or removing
  3. "[delimiter]" ;[delimiter]
  4. ; one or several symbols
  5. "[E][options]" ;[options]
  6. ; +string2 : words to add
  7. ; -string2 : words to delete
  8. ;
  9. ;[E]
  10. ; with errorlevel output
  11. ; IfErrors:
  12. ; $var=1 delimiter is empty
  13. ; $var=3 syntax error (use: +text,-text)
  14. ;[]
  15. ; no errorlevel output (default)
  16. ; If some errors found then (result=input string)
  17. ;
  18. $var ;output (result)

Example (add):

  1. Section
  2. ${WordAdd} "C:\io.sys C:\WINDOWS" " " "+C:\WINDOWS C:\config.sys" $R0
  3. ; $R0="C:\io.sys C:\WINDOWS C:\config.sys"
  4. SectionEnd

Example (delete):

  1. Section
  2. ${WordAdd} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "-C:\WINDOWS C:\config.sys C:\IO.SYS" $R0
  3. ; $R0="C:\logo.sys"
  4. SectionEnd

Example (add to one):

  1. Section
  2. ${WordAdd} "C:\io.sys" " " "+C:\WINDOWS C:\config.sys C:\IO.SYS" $R0
  3. ; $R0="C:\io.sys C:\WINDOWS C:\config.sys"
  4. SectionEnd

Example (delete one):

  1. Section
  2. ${WordAdd} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "-C:\WINDOWS" $R0
  3. ; $R0="C:\io.sys C:\logo.sys"
  4. SectionEnd

Example (No new words found):

  1. Section
  2. ${WordAdd} "C:\io.sys C:\logo.sys" " " "+C:\logo.sys" $R0
  3. StrCmp $R0 "C:\io.sys C:\logo.sys" 0 +2
  4. MessageBox MB_OK "No new words found to add"
  5. SectionEnd

Example (No words deleted):

  1. Section
  2. ${WordAdd} "C:\io.sys C:\logo.sys" " " "-C:\config.sys" $R0
  3. StrCmp $R0 "C:\io.sys C:\logo.sys" 0 +2
  4. MessageBox MB_OK "No words found to delete"
  5. SectionEnd

Example (With errorlevel output):

  1. Section
  2. ${WordAdd} "C:\io.sys C:\logo.sys" "" "E-C:\logo.sys" $R0
  3. ; $R0="1" (delimiter is empty "")
  4.  
  5. IfErrors 0 noerrors
  6. MessageBox MB_OK 'Errorlevel=$R0' IDOK end
  7.  
  8. noerrors:
  9. MessageBox MB_OK 'No errors'
  10.  
  11. end:
  12. SectionEnd

E.3.11 WordAddS

  • Same as WordAdd, but case sensitive.

E.3.12 WordInsert

  • Insert word in string.

Syntax:

  1. ${WordInsert} "[string]" "[delimiter]" "[word]" "[E][options]" $var
  1. "[string]" ;[string]
  2. ; input string
  3. "[delimiter]" ;[delimiter]
  4. ; one or several symbols
  5. "[word]" ;[word]
  6. ; word to insert
  7. "[E][options]" ;[options]
  8. ; +number : word number from start
  9. ; -number : word number from end
  10. ;
  11. ;[E]
  12. ; with errorlevel output
  13. ; IfErrors:
  14. ; $var=1 delimiter is empty
  15. ; $var=2 wrong word number
  16. ; $var=3 syntax error (Use: +1,-1)
  17. ;[]
  18. ; no errorlevel output (default)
  19. ; If some errors found then (result=input string)
  20. ;
  21. $var ;output (result)

Example (1):

  1. Section
  2. ${WordInsert} "C:\io.sys C:\WINDOWS" " " "C:\logo.sys" "-2" $R0
  3. ; $R0="C:\io.sys C:\logo.sys C:\WINDOWS"
  4. SectionEnd

Example (2):

  1. Section
  2. ${WordInsert} "C:\io.sys" " " "C:\WINDOWS" "+2" $R0
  3. ; $R0="C:\io.sys C:\WINDOWS"
  4. SectionEnd

Example (3):

  1. Section
  2. ${WordInsert} "" " " "C:\WINDOWS" "+1" $R0
  3. ; $R0="C:\WINDOWS "
  4. SectionEnd

Example (With errorlevel output):

  1. Section
  2. ${WordInsert} "C:\io.sys C:\logo.sys" " " "C:\logo.sys" "E+4" $R0
  3. ; $R0="2" (wrong word number "+4")
  4.  
  5. IfErrors 0 noerrors
  6. MessageBox MB_OK 'Errorlevel=$R0' IDOK end
  7.  
  8. noerrors:
  9. MessageBox MB_OK 'No errors'
  10.  
  11. end:
  12. SectionEnd

E.3.13 WordInsertS

E.3.14 StrFilter

  • Convert string to uppercase or lowercase.
  • Set symbol filter.

Syntax:

  1. ${StrFilter} "[string]" "[options]" "[symbols1]" "[symbols2]" $var
  1. "[string]" ;[string]
  2. ; input string
  3. ;
  4. "[options]" ;[+|-][1|2|3|12|23|31][eng|rus]
  5. ; + : convert string to uppercase
  6. ; - : convert string to lowercase
  7. ; 1 : only Digits
  8. ; 2 : only Letters
  9. ; 3 : only Special
  10. ; 12 : only Digits + Letters
  11. ; 23 : only Letters + Special
  12. ; 31 : only Special + Digits
  13. ; eng : English symbols (default)
  14. ; rus : Russian symbols
  15. ;
  16. "[symbols1]" ;[symbols1]
  17. ; symbols include (not changeable)
  18. ;
  19. "[symbols2]" ;[symbols2]
  20. ; symbols exclude
  21. ;
  22. $var ;output (result)

Note:- Error flag if syntax error - Same symbol to include & to exclude = to exclude

Example (UpperCase):

  1. Section
  2. ${StrFilter} "123abc 456DEF 7890|%#" "+" "" "" $R0
  3. ; $R0="123ABC 456DEF 7890|%#"
  4. SectionEnd

Example (LowerCase):

  1. Section
  2. ${StrFilter} "123abc 456DEF 7890|%#" "-" "ef" "" $R0
  3. ; $R0="123abc 456dEF 7890|%#"
  4. SectionEnd

Example (Filter1):

  1. Section
  2. ${StrFilter} "123abc 456DEF 7890|%#" "2" "|%" "" $R0
  3. ; $R0="abcDEF|%" ;only Letters + |%
  4. SectionEnd

Example (Filter2):

  1. Section
  2. ${StrFilter} "123abc 456DEF 7890|%#" "13" "af" "4590" $R0
  3. ; $R0="123a 6F 78|%#" ;only Digits + Special + af - 4590
  4. SectionEnd

Example (Filter3):

  1. Section
  2. ${StrFilter} "123abc 456DEF 7890|%#" "+12" "b" "def" $R0
  3. ; $R0="123AbC4567890" ;only Digits + Letters + b - def
  4. SectionEnd

Example (Filter4):

  1. Section
  2. ${StrFilter} "123abcÀÁÂ 456DEFãäå 7890|%#" "+12rus" "ä" "ãå" $R0
  3. ; $R0="123ÀÁÂ456ä7890" ;only Digits + Letters + ä - ãå
  4. SectionEnd

Example (English + Russian Letters):

  1. Section
  2. ${StrFilter} "123abcÀÁÂ 456DEFãäå 7890|%#" "2rus" "" "" $R0
  3. ; $R0="ÀÁÂãäå" ;only Russian Letters
  4. ${StrFilter} "123abcÀÁÂ 456DEFãäå 7890|%#" "2" "$R0" "" $R0
  5. ; $R0="abcÀÁÂDEFãäå" ;only English + Russian Letters
  6. SectionEnd

Example (Word Capitalize):

  1. Section
  2. Push "_01-PERPETUOUS_DREAMER__-__THE_SOUND_OF_GOODBYE_(ORIG._MIX).MP3_"
  3. Call Capitalize
  4. Pop $R0
  5. ; $R0="_01-Perpetuous_Dreamer__-__The_Sound_Of_Goodbye_(Orig._Mix).mp3_"
  6.  
  7. ${WordReplace} "$R0" "_" " " "+*" $R0
  8. ; $R0=" 01-Perpetuous Dreamer - The Sound Of Goodbye (Orig. Mix).mp3 "
  9.  
  10. ${WordReplace} "$R0" " " "" "{}" $R0
  11. ; $R0="01-Perpetuous Dreamer - The Sound Of Goodbye (Orig. Mix).mp3"
  12. SectionEnd
  13.  
  14. Function Capitalize
  15. Exch $R0
  16. Push $0
  17. Push $1
  18. Push $2
  19.  
  20. ${StrFilter} '$R0' '-eng' '' '' $R0
  21. ${StrFilter} '$R0' '-rus' '' '' $R0
  22.  
  23. StrCpy $0 0
  24.  
  25. loop:
  26. IntOp $0 $0 + 1
  27. StrCpy $1 $R0 1 $0
  28. StrCmp $1 '' end
  29. StrCmp $1 ' ' +5
  30. StrCmp $1 '_' +4
  31. StrCmp $1 '-' +3
  32. StrCmp $1 '(' +2
  33. StrCmp $1 '[' 0 loop
  34. IntOp $0 $0 + 1
  35. StrCpy $1 $R0 1 $0
  36. StrCmp $1 '' end
  37.  
  38. ${StrFilter} '$1' '+eng' '' '' $1
  39. ${StrFilter} '$1' '+rus' '' '' $1
  40.  
  41. StrCpy $2 $R0 $0
  42. IntOp $0 $0 + 1
  43. StrCpy $R0 $R0 '' $0
  44. IntOp $0 $0 - 2
  45. StrCpy $R0 '$2$1$R0'
  46. goto loop
  47.  
  48. end:
  49. Pop $2
  50. Pop $1
  51. Pop $0
  52. Exch $R0
  53. FunctionEnd

E.3.15 StrFilterS

E.3.16 VersionCompare

  • Compare version numbers.

Syntax:

  1. ${VersionCompare} "[Version1]" "[Version2]" $var
  1. "[Version1]" ; First version
  2. "[Version2]" ; Second version
  3. $var ; Result:
  4. ; $var=0 Versions are equal
  5. ; $var=1 Version1 is newer
  6. ; $var=2 Version2 is newer

Example:

  1. Section
  2. ${VersionCompare} "1.1.1.9" "1.1.1.01" $R0
  3. ; $R0="1"
  4. SectionEnd

E.3.17 VersionConvert

  • Convert version in the numerical format which can be compared.

Syntax:

  1. ${VersionConvert} "[Version]" "[CharList]" $var
  1. "[Version]" ; Version
  2. ;
  3. "[CharList]" ; List of characters, which will be replaced by numbers
  4. ; "abcdefghijklmnopqrstuvwxyz" (default)
  5. ;
  6. $var ; Result: converted version

Note:- Converted letters are separated with dot - If character is non-digit and not in list then it will be converted to dot

Example1:

  1. Section
  2. ${VersionConvert} "9.0a" "" $R0
  3. ; $R0="9.0.01"
  4.  
  5. ${VersionConvert} "9.0c" "" $R1
  6. ; $R1="9.0.03"
  7.  
  8. ${VersionCompare} "$R0" "$R1" $R2
  9. ; $R2="2" version2 is newer
  10. SectionEnd

Example2:

  1. Section
  2. ${VersionConvert} "0.15c-9m" "" $R0
  3. ; $R0="0.15.03.9.13"
  4.  
  5. ${VersionConvert} "0.15c-1n" "" $R1
  6. ; $R1="0.15.03.1.14"
  7.  
  8. ${VersionCompare} "$R0" "$R1" $R2
  9. ; $R2="1" version1 is newer
  10. SectionEnd

Example3:

  1. Section
  2. ${VersionConvert} "0.15c+" "abcdefghijklmnopqrstuvwxyz+" $R0
  3. ; $R0="0.15.0327"
  4.  
  5. ${VersionConvert} "0.15c" "abcdefghijklmnopqrstuvwxyz+" $R1
  6. ; $R1="0.15.03"
  7.  
  8. ${VersionCompare} "$R0" "$R1" $R2
  9. ; $R2="1" version1 is newer
  10. SectionEnd