AppendixE.html 80 KB

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