1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>DC - Lua Scripting</title>
<link rel="stylesheet" type="text/css" href="doublecmd.css">
<link rel="shortcut icon" href="../../pixmaps/common/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<a name="topofpage"></a>
<div class="header"><a href="index.html"><img src="../../pixmaps/common/dclogo2017.png" alt="Double Commander" height="48" width="374"></a>
<div id="global-nav" class="nav"><a title="Double Commander Home Page" href="https://doublecmd.sourceforge.io/" target="_blank">Homepage</a> | <a title="Double Commander Wiki" href="https://github.com/doublecmd/doublecmd/wiki" target="_blank">Wiki</a></div>
</div>
<div class="footer"><div class="nav"><a title="Index" href="index.html">Index</a> | <a title="Previous page" href="regexp.html">Previous</a> | <a title="Next page" href="commandline.html">Next</a></div></div>
<div class="dchelpage">
<div>
<h1>2.15. Lua Scripting</h1>
</div>
<div>
<h2>Content</h2>
<dl>
<dt>1. <a href="#preface">Introduction</a></dt>
<dt>2. <a href="#dllrequired">DLL required</a></dt>
<dt>3. <a href="#libraries">Double Commander functions libraries</a></dt>
<dd>
<dl>
<dt>3.1. <a href="#libdc">DC library</a></dt>
<dd>
<dl>
<dt>3.1.1. <a href="#exampleex">Example with the DC.ExecuteCommand</a></dt>
</dl>
</dd>
<dt>3.2. <a href="#librarysystem">System library</a></dt>
<dd>
<dl>
<dt>3.2.1. <a href="#detailattr">Details on SysUtils.FileGetAttr returned value</a></dt>
<dt>3.2.2. <a href="#exampleattr">Example with SysUtils.FileGetAttr</a></dt>
<dt>3.2.3. <a href="#examplefind">Example using FindFirst, FindNext and FindClose</a></dt>
</dl>
</dd>
<dt>3.3. <a href="#libraryclip">Clipboard library</a></dt>
<dd>
<dl>
<dt>3.3.1. <a href="#exampleclip">Example of usage clipboard library</a></dt>
</dl>
</dd>
<dt>3.4. <a href="#librarydialogs">Dialogs library</a></dt>
<dd>
<dl>
<dt>3.4.1. <a href="#dlgbuts">Buttons displayed in Dialogs.MessageBox</a></dt>
<dt>3.4.2. <a href="#dlgstyle">Style of box of Dialogs.MessageBox</a></dt>
<dt>3.4.3. <a href="#dlgdefbut">Default active button of Dialogs.MessageBox</a></dt>
<dt>3.4.4. <a href="#msgreturn">Returned value of Dialogs.MessageBox</a></dt>
<dt>3.4.5. <a href="#mesgboxsample">Example of usage of the Dialogs.MessageBox</a></dt>
<dt>3.4.6. <a href="#querysample">Example of usage of the Dialogs.InputQuery</a></dt>
</dl>
</dd>
<dt>3.5. <a href="#libraryutf8">UTF-8 library</a></dt>
<dt>3.6. <a href="#librarychar">Char library</a></dt>
<dt>3.7. <a href="#libraryos">OS library</a></dt>
</dl>
</dd>
<dt>4. <a href="#index">Index</a></dt>
</dl>
</div>
<div>
<h2><a name="preface">1. Introduction</a></h2>
<p>Detailed information about the Lua scripting programming language can be found on the <a href="https://www.lua.org/" target="_blank">Lua website</a>.</p>
<p>Double Commander can execute Lua scripts via <a href="cmds.html#cm_ExecuteScript">cm_ExecuteScript</a> command.<br>
Script parameters must be passed as is, without escaping (without quotes or "\"), for this we need to use the <a href="variables.html#quotation">%"0</a> variable: for example, <code>%"0%p0</code> for the file under cursor instead of <code>%p0</code> or <code>%"0%D</code> for the current directory instead of <code>%D</code>. Otherwise, if Double Commander automatically adds quotes, they will be passed as part of the parameter and you will have to take them into account.<br>
To get a list of all selected files we can use <a href="variables.html#listoffiles">variables</a> (<code>%LU</code>, <code>%FU</code> or <code>%RU</code>) or internal commands (<a href="cmds.html#cm_SaveSelectionToFile">cm_SaveSelectionToFile</a>, <a href="cmds.html#cm_SaveFileDetailsToFile">cm_SaveFileDetailsToFile</a>, <a href="cmds.html#cm_CopyFullNamesToClip">cm_CopyFullNamesToClip</a> or <a href="cmds.html#cm_CopyFileDetailsToClip">cm_CopyFileDetailsToClip</a>).
We can use, for example, <code>%p</code>: in this case, Double Commander will pass the names of all selected files in one line, separating the names with a space.</p>
<p>It is also possible to write content plugins using Lua script, examples can be found in the program folder (<tt>plugins/wdx/scripts</tt>).
The Wiki has a <a href="https://github.com/doublecmd/doublecmd/wiki/Plugins-development" target="_blank">page</a> dedicated to writing plugins.
Limitations: only the following data types are supported</p>
<ul>
<li><i>ft_numeric_32</i> (1) – a 32-bit signed number;</li>
<li><i>ft_numeric_64</i> (2) – a 64-bit signed number;</li>
<li><i>ft_numeric_floating</i> (3) – a floating point number;</li>
<li><i>ft_boolean</i> (6) – boolean type: <i>true</i> or <i>false</i>;</li>
<li><i>ft_multiplechoice</i> (7) – a value allowing a limited number of choices;</li>
<li><i>ft_string</i> (8) – a text string;</li>
<li><i>ft_fulltext</i> (9) – a full text (multiple text strings), used only for searching with plugins ;</li>
<li><i>ft_datetime</i> (10) – for date/time: a returned date will be converted to a formatted date and time string (value depends on your regional settings).<br>
The date must be in Windows format, but Lua and the functions that Double Commander provides for searching files use Unix time format. To convert we can use the formula:<br>
= UnixTime * 10000000 + 116444736000000000<br>
This is a large number, so you will need a 64-bit version of Double Commander or Lua 5.3+.</li>
</ul>
<p>The list above contains the names from the header files, in Lua scripts we must use the numeric values which are specified in parentheses.</p>
<br>
<p><span class="bold">About text encoding</span></p>
<p>All additional functions described below accept string parameters in UTF-8 encoding and return strings in this encoding (except for the <a href="#libraryutf8">LazUtf8.ConvertEncoding</a> function).</p>
<p>Some functions from the standard Lua libraries have been replaced with functions from Double Commander or Free Pascal/Lazarus (or new ones have been written), this provides UTF-8 support.</p>
<p>When writing plugins, we should also use UTF-8 for text data (<i>ft_multiplechoice</i>, <i>ft_string</i> and <i>ft_fulltext</i>).</p>
<p>When saving scripts, use UTF-8 encoding without BOM.</p>
<br>
<p><span class="bold">Notes</span></p>
<p>Automation with Lua has great possibilities, but there may be nuances that in some cases need to be kept in mind. Let's try to collect them in this subsection.</p>
<p>1. If <a href="configuration.html#ConfigRefresh">auto refresh</a> and the <a href="configuration.html#ConfigViewEx">Load file list in separate thread</a> option are enabled, the refresh function will work asynchronously. At the same time, scripts are executed in the main thread of Double Commander and therefore, in some cases, all this may affect the operation of your script. For example, sometimes sequential execution of <a href="cmds.html#catnavigation">commands for navigation</a> may not work (for example, large directories, slow disk), in this case try to disable <i>Load file list in separate thread</i> or look for an alternative solution.</p>
<p>If your script creates new files in the current panel or renames existing files, but then does not complete and performs some additional actions (for example, selecting files or moving the cursor), then in some cases these actions will not have an effect: not all files may be in the panel yet and you will need to first call the <a href="cmds.html#cm_Refresh">cm_Refresh</a> command. Under the described conditions, <tt>cm_Refresh</tt> will also be executed asynchronously and Double Commander may not have time to completely refresh the list of files after your changes.</p>
<p>Auto-refreshing and loading the list of files in a separate thread are convenient functions for a file manager, so the stable working method was experimentally found to temporarily return control to the program and allow the file list to be completely refreshed:</p>
<pre>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">"cm_Refresh"</span><span class="luasbl">)</span>
i <span class="luasbl">=</span> <span class="luanum">10</span>
<span class="luakyw">while</span> i <span class="luasbl">></span> <span class="luanum">0</span> <span class="luakyw">do</span>
SysUtils.Sleep<span class="luasbl">(</span><span class="luanum">10</span><span class="luasbl">)</span>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">""</span><span class="luasbl">)</span>
i <span class="luasbl">=</span> i <span class="luasbl">-</span> <span class="luanum">1</span>
<span class="luakyw">end</span></pre>
<p>2. Lua function <code>io.open</code> uses the standard C function <code>fopen</code>: in text mode, this function can convert the type of line endings (CRLF, LF or CR) when reading and writing and it can lead to unexpected results. If you come across files with different types of line endings or if you are writing a cross-platform script, this must be taken into account or it may be more practical to give preference to the binary mode.</p>
<p>3. For the <a href="help.html#cm_FileProperties">file properties</a> dialog in Linux and other Unix-like operating systems, the <code>ContentGetValue</code> function is called with the <code>CONTENT_DELAYIFSLOW</code> flag (the fourth parameter, the value is 1), this avoids the delay in opening the window: if data retrieval is slow, we can exclude this data by simply adding a flag value check and returning <code>nil</code> for such fields or plugin.</p>
<p>4. If the plugin should return an empty string, it will be faster to pass <code>nil</code> instead of <code>""</code>.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="dllrequired">2. DLL required</a></h2>
<p>In order to interpret Lua script file, we need to have a Lua DLL file, Double Commander supports versions 5.1 - 5.4.</p>
<p>By default DC looks for a file with name <tt>lua5.1.dll</tt> (Windows), <tt>liblua5.1.so.0</tt> (Unix or GNU/Linux) or <tt>liblua5.1.dylib</tt> (macOS) in its directory and in the system directory. We can change the file name (and path) in the <a href="configuration.html#luapathtolibrary">Lua library file to use</a> parameter.</p>
<p>We can use DLL file from <a href="https://luajit.org/" target="_blank">LuaJIT project</a>.
LuaJIT combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler. Also we get FFI library, which allows calling external C functions and using C data structures from pure Lua code.</p>
<p>DC distributives for Windows have Lua DLL by default (in DC 0.9.7 and newer from LuaJIT project), in other cases we may find and install it through our packages manager or compile it. If we're using a 64-bits version of DC, the DLL must be the 64-bits version as well.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="libraries">3. Double Commander functions libraries</a></h2>
<p>Double Commander offer a few libraries of functions for our Lua scripts.</p>
<p>Here is the list of them.</p>
<table>
<tr class="rowcategorytitle"><th colspan="3">List of libraries</th></tr>
<tr class="rowsubtitle"><th class="namecolumn">Library name</th><th class="namecolumn">Script name</th><th class="categorydesccolumn">Quick description</th></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#libdc">Double Commander library</a></div></td><td class="hintcell">DC</td><td class="hintcell">Double Commander specific functions</td></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#librarysystem">System library</a></div></td><td class="hintcell">SysUtils</td><td class="hintcell">Various system functions</td></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#libraryclip">Clipboard library</a></div></td><td class="hintcell">Clipbrd</td><td class="hintcell">Provides external clipboard functionality</td></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#librarydialogs">Dialogs library</a></div></td><td class="hintcell">Dialogs</td><td class="hintcell">Interacts with user</td></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#libraryutf8">UTF-8 library</a></div></td><td class="hintcell">LazUtf8</td><td class="hintcell">UTF-8 string functions</td></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#librarychar">Char library</a></div></td><td class="hintcell">Char</td><td class="hintcell">Getting information about characters</td></tr>
<tr><td class="varcell"><div class="firstcolumnaleft"><a href="#libraryos">OS library</a></div></td><td class="hintcell">os</td><td class="hintcell">Functions related with the operating system</td></tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="libdc">3.1. DC library</a></h2>
<p>This library contains Double Commander specific functions.</p>
<p>It provides all its functions inside the table <code>DC</code>.</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">DC library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="dc_logwrite">DC.LogWrite</a></div></td>
<td class="hintcell">
<p class="definition">DC.LogWrite(sMessage, iMsgType, bForce, bLogFile)</p>
<p>Write a message to the log window:</p>
<ul>
<li><var>sMessage</var> : The message text.</li>
<li><var>iMsgType</var> : The message type: 0 - information, 1 - success, 2 - error.</li>
<li><var>bForce</var> : A boolean, when true, will show the log window if invisible.</li>
<li><var>bLogFile</var> : A boolean, when true, will write the message also in the log file.</li>
</ul>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="dc_currentpanel">DC.CurrentPanel</a></div></td>
<td class="hintcell">
<p class="definition">iPanel = DC.CurrentPanel()</p>
<p>Get active panel: returns 0 if left panel is active or 1 if right.</p>
<p class="definition">DC.CurrentPanel(iPanel)</p>
<p>Set active panel: left panel if <var>iPanel</var> equal 0 or right if 1.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="dc_executecommand">DC.ExecuteCommand</a></div></td>
<td class="hintcell">
<p class="definition">DC.ExecuteCommand(sCommand, Param1, Param2,...,ParamX)</p>
<p>This allows the script to invoke <a href="cmds.html">internal commands</a> of Double Commander.</p>
<p>The <var>sCommand</var> is holding the actual internal command name.</p>
<p>We may provide as many <var>Param...</var> as command may support.</p>
</td>
</tr>
</table>
<p>In addition to internal commands, in scripts we can use the special command <tt>cm_ExecuteToolBarItem</tt>, this command allows to call toolbar buttons by their identifier (in the program, this function provides the use of hotkeys for toolbar buttons). The command is used similarly to ordinary internal commands (see examples below) and has the following parameters:</p>
<table class="innercmddesc">
<tr class="rowinnerdesc">
<th class="innerdescheader">Parameter</th>
<th class="innerdescheader">Value</th>
<th class="innerdescheader">Description</th>
</tr>
<tr>
<td class="innerdescparamcell" rowspan="3">ToolBarID</td>
<td class="innerdescvaluecell">TfrmOptionsToolbar</td>
<td class="innerdescdesccell">the button of the main toolbar</td>
</tr>
<tr>
<td class="innerdescvaluecell">TfrmOptionsToolbarMiddle</td>
<td class="innerdescdesccell">the button of the middle toolbar</td>
</tr>
<tr>
<td class="innerdescvaluecell"><i>(absent)</i></td>
<td class="innerdescdesccell">the button of the main toolbar</td>
</tr>
<tr>
<td class="innerdescparamcell">ToolItemID</td>
<td class="innerdescvaluecell"><i>identifier</i></td>
<td class="innerdescdesccell">the unique identifier of the button</td>
</tr>
</table>
<p>The unique identifier is stored in the <code>ID</code> tag and we have several ways to get it: we can find the button in the <tt>doublecmd.xml</tt> file, in the toolbar backup file, or simply copy the button to the clipboard and paste its code into a text editor.</p>
<p>Note: Identifiers are generated automatically and do not have to match the identifiers of similar buttons in another copy of the program, but if necessary, we can manually set our own value.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="exampleex">3.1.1. Example with the DC.ExecuteCommand</a></h2>
<p>In this example, we wrote a simple script that will do the following:</p>
<ol>
<li>focus to right panel</li>
<li>close all opened tabs</li>
<li>switch to a specific folder</li>
<li>focus the left panel</li>
<li>close all opened tabs</li>
<li>switch to a specific folder</li>
<li>open a new tab</li>
<li>switch to a specific folder</li>
</ol>
<pre>
<span class="luacmt">-- 1. Focus on right panel.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_FocusSwap"</span><span class="luasbl">,</span> <span class="luastr">"side=right"</span><span class="luasbl">)</span>
<span class="luacmt">-- 2. Close all tabs.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_CloseAllTabs"</span><span class="luasbl">)</span>
<span class="luacmt">-- 3. Switch to a specific directory.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_ChangeDir"</span><span class="luasbl">,</span> <span class="luastr">"E:\\FakeKey\\Documents\\Music"</span><span class="luasbl">)</span>
<span class="luacmt">-- 4. Focus on left panel.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_FocusSwap"</span><span class="luasbl">,</span> <span class="luastr">"side=left"</span><span class="luasbl">)</span>
<span class="luacmt">-- 5. Close all tabs.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_CloseAllTabs"</span><span class="luasbl">)</span>
<span class="luacmt">-- 6. Switch to a specific directory.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_ChangeDir"</span><span class="luasbl">,</span> <span class="luastr">"C:\\Users\\Public\\Music"</span><span class="luasbl">)</span>
<span class="luacmt">-- 7. Open a new tab.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_NewTab"</span><span class="luasbl">)</span>
<span class="luacmt">-- 8. Switch to a specific directory.</span>
<span class="mark">DC.ExecuteCommand</span><span class="luasbl">(</span><span class="luastr">"cm_ChangeDir"</span><span class="luasbl">,</span> <span class="luastr">"E:\\VirtualMachines\\ShareFolder"</span><span class="luasbl">)</span></pre>
<p>Using the internal command <a href="cmds.html#cm_ExecuteScript">cm_ExecuteScript</a>, we may configure a tool bar button that will execute our script.</p>
<p>Assuming this script file is <code>E:\scripts\lua\music.lua</code>, we could have the button configured this way:</p>
<p class="figure"><img class="largeimage" title="Invoking a Lua script from toolbar" alt="Invoking a Lua script from toolbar" src="images/imgDC/luaimg1.png" width="560" height="290"></p>
<p>Also, we may use the internal Double Commander Editor for editing our scripts. If filename has <code>.lua</code> file extension, it will be recognized by internal editor and it will provide us syntax highlighting specific for this Lua language:</p>
<p class="figure"><img class="largeimage" title="Lua syntax highlighting with internal editor" alt="Lua syntax highlighting with internal editor" src="images/imgDC/luaimg2.png" width="660" height="480"></p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="librarysystem">3.2. System library</a></h2>
<p>This library contains various system functions.</p>
<p>It provides all its functions inside the table <code>SysUtils</code>.</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">System library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_sleep">SysUtils.Sleep</a></div></td>
<td class="hintcell">
<p class="definition">SysUtils.Sleep(iMilliseconds)</p>
<p>Suspends the execution of the script for the specified number of <var>iMilliseconds</var>.<br>After the specified period has expired, script execution resumes.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_gettickcount">SysUtils.GetTickCount</a></div></td>
<td class="hintcell">
<p class="definition">SysUtils.GetTickCount()</p>
<p>Returns an increasing clock tick count. It is useful for time measurements, but no assumptions should be made as to the interval between the ticks.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_fileexists">SysUtils.FileExists</a></div></td>
<td class="hintcell">
<p class="definition">bExists = SysUtils.FileExists(sFileName)</p>
<p>Check whether a particular file exists in the filesystem.</p>
<p>Returns in <var>bExists</var> the value <code>true</code> if file with name <var>sFileName</var> exists on the disk, or <code>false</code> otherwise.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_directoryexists">SysUtils.DirectoryExists</a></div></td>
<td class="hintcell">
<p class="definition">bExists = SysUtils.DirectoryExists(sDirectory)</p>
<p>Checks whether <var>sDirectory</var> exists in the filesystem and is actually a directory.</p>
<p>If this is the case, the function returns in <var>bExists</var> the value <code>true</code> otherwise <code>false</code> is returned.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_filegetattr">SysUtils.FileGetAttr</a></div></td>
<td class="hintcell">
<p class="definition">iAttr = SysUtils.FileGetAttr(sFileName)</p>
<p>Returns in <var>iAttr</var> the attribute settings of file <var>sFileName</var>.</p>
<p>See the detail explanations of the returned value <a href="#detailattr">here</a>.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_findfirst">SysUtils.FindFirst</a></div></td>
<td class="hintcell">
<p class="definition">Handle, FindData = SysUtils.FindFirst(sPath)</p>
<p>Looks for files that match the <var>sPath</var>, generally with wildcards.</p>
<p>If no file is found, <var>Handle</var> will be <code>nil</code>.</p>
<p>When at least one item is found, the returned <var>Handle</var> may be used in subsequent <code>SysUtils.FindNext</code> to find other occurrences of the same pattern.</p>
<p>The <var>FindData</var> table contains information about the file or directory found.</p>
<p>The field of the <var>FindData</var> table are:</p>
<ul>
<li><var>Name</var> : The file name (without path).</li>
<li><var>Attr</var> : The file attributes of the file (see details <a href="#detailattr">here</a>).</li>
<li><var>Size</var> : The size of the file in bytes.</li>
<li><var>Time</var> : The time stamp of the file (seconds since Jan 01 1970)</li>
</ul>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_findnext">SysUtils.FindNext</a></div></td>
<td class="hintcell">
<p class="definition">Result, FindData = SysUtils.FindNext(Handle)</p>
<p>Finds the next occurrence of a search sequence initiated by <code >FindFirst</code> by re-using the <var>Handle</var> returned previously.</p>
<p>Returned <var>Result</var> will be non-nil if a file or directory is found and will be <code>nil</code> otherwise.</p>
<p>The same notes mentioned for <code>SysUtils.FindFirst</code> applied here.</p>
<p><b><span class="uline">Remark:</span> The last <code>SysUtils.FindNext</code> call must always be followed by a <code>SysUtils.FindClose</code> call with the same <var>Handle</var>. Failure to do so will result in memory leaks.</b></p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_findclose">SysUtils.FindClose</a></div></td>
<td class="hintcell">
<p class="definition">SysUtils.FindClose(Handle)</p>
<p>Ends a series of <code>SysUtils.FindFirst</code>/<code>SysUtils.FindNext</code> calls.</p>
<p>Frees any memory used by these calls.</p>
<p>It is <em>absolutely</em> necessary to do this call, or memory losses may occur.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_createdirectory">SysUtils.CreateDirectory</a></div></td>
<td class="hintcell">
<p class="definition">bResult = SysUtils.CreateDirectory(sDirectory)</p>
<p>Create a chain of directories, <var>sDirectory</var> is the full path to directory.</p>
<p>Returns <code>true</code> if <var>sDirectory</var> already exist or was created successfully. If it failed to create any of the parts, <code>false</code> is returned.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_createhardlink">SysUtils.CreateHardLink</a></div></td>
<td class="hintcell">
<p class="definition">bResult = SysUtils.CreateHardLink(sFileName, sLinkName)</p>
<p>Create the hard link <var>sLinkName</var> to file <var>sFileName</var>.</p>
<p>Returns <code>true</code> if successful, <code>false</code> otherwise.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_createsymboliclink">SysUtils.CreateSymbolicLink</a></div></td>
<td class="hintcell">
<p class="definition">bResult = SysUtils.CreateSymbolicLink(sFileName, sLinkName)</p>
<p>Create the symbolic link <var>sLinkName</var> to file or directory <var>sFileName</var>.</p>
<p>Returns <code>true</code> if successful, <code>false</code> otherwise.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_readsymboliclink">SysUtils.ReadSymbolicLink</a></div></td>
<td class="hintcell">
<p class="definition">sTarget = SysUtils.ReadSymbolicLink(sLinkName, bRecursive)</p>
<p>Read destination of the symbolic link <var>sLinkName</var>.</p>
<p>If <var>bRecursive</var> is <code>true</code> and the link points to a link then it's resolved recursively until a valid file name that is not a link is found.</p>
<p>Returns the path where the symbolic link <var>sLinkName</var> is pointing to or an empty string when the link is invalid or the file it points to does not exist and <var>bRecursive</var> is <code>true</code>.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_extractfilename">SysUtils.ExtractFileName</a></div></td>
<td class="hintcell">
<p class="definition">sName = SysUtils.ExtractFileName(sFileName)</p>
<p>Extract the filename part from a full path filename.</p>
<p>The filename consists of all characters after the last directory separator character ("/" or "\") or drive letter.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_extractfileext">SysUtils.ExtractFileExt</a></div></td>
<td class="hintcell">
<p class="definition">sExt = SysUtils.ExtractFileExt(sFileName)</p>
<p>Return the extension from a filename (all characters after the last "." (dot), including the "." character).</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_extractfilepath">SysUtils.ExtractFilePath</a></div></td>
<td class="hintcell">
<p class="definition">sPath = SysUtils.ExtractFilePath(sFileName)</p>
<p>Extract the path from a filename (including drive letter).</p>
<p>The path consists of all characters before the last directory separator character ("/" or "\"), including the directory separator itself.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_extractfiledir">SysUtils.ExtractFileDir</a></div></td>
<td class="hintcell">
<p class="definition">sDir = SysUtils.ExtractFileDir(sFileName)</p>
<p>Extract only the directory part of <var>sFileName</var>, including a drive letter.</p>
<p>The directory name has NO ending directory separator, in difference with <code>SysUtils.ExtractFilePath</code>.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_extractfiledrive">SysUtils.ExtractFileDrive</a></div></td>
<td class="hintcell">
<p class="definition">sDrive = SysUtils.ExtractFileDrive(sFileName)</p>
<p>Extract the drive part from a filename.</p>
<p>Note that some operating systems do not support drive letters.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_getabsolutepath">SysUtils.GetAbsolutePath</a></div></td>
<td class="hintcell">
<p class="definition">sName = SysUtils.GetAbsolutePath(sFileName, sBaseDirectory)</p>
<p>Returns the absolute (full) path to the file:</p>
<ul>
<li><var>sFileName</var> : The filename with a relative path.</li>
<li><var>sBaseDirectory</var> : The directory that was used as the base directory for <var>sFileName</var>.</li>
</ul>
<p>If the absolute path could not be obtained, the function will return the <var>sFileName</var> value.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_getrelativepath">SysUtils.GetRelativePath</a></div></td>
<td class="hintcell">
<p class="definition">sName = SysUtils.GetRelativePath(sFileName, sBaseDirectory)</p>
<p>Returns the filename relative to the specified directory:</p>
<ul>
<li><var>sFileName</var> : The full (absolute) filename.</li>
<li><var>sBaseDirectory</var> : The directory that will be used as the base directory <var>sFileName</var>.</li>
</ul>
<p>If <var>sFileName</var> and <var>sBaseDirectory</var> contain the same value, the function will return an empty string (""). If it was not possible to get the file name with a relative path, the function will return the <var>sFileName</var> value.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_matchesmask">SysUtils.MatchesMask</a></div></td>
<td class="hintcell">
<p class="definition">bResult = SysUtils.MatchesMask(sFileName, sMask, iMaskOptions)</p>
<p>Returns <code>true</code> if <var>sFileName</var> matches the passed mask <var>sMask</var>.</p>
<p><var>iMaskOptions</var> (optional parameter, 0 by default) is set as the sum of the following values:</p>
<table class="innercmddesc">
<tr class="rowinnerdesc">
<th class="innerdescheader">Value</th>
<th class="innerdescheader">Description</th>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">1</div></td>
<td class="hintcell">case sensitive</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">2</div></td>
<td class="hintcell">ignore accents and ligatures</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">4</div></td>
<td class="hintcell">Windows style filter: "*.*" also match files without extension, etc.</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">8</div></td>
<td class="hintcell">enable pinyin support (file <tt>pinyin.tbl</tt> will be used)</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_matchesmasklist">SysUtils.MatchesMaskList</a></div></td>
<td class="hintcell">
<p class="definition">bResult = SysUtils.MatchesMaskList(sFileName, sMaskList, sSeparator, iMaskOptions)</p>
<p>Returns <code>true</code> if <var>sFileName</var> matches at least one of passed masks <var>sMaskList</var> separated by <var>sSeparator</var> (";" by default).</p>
<p><var>sSeparator</var> and <var>iMaskOptions</var> (see above) are optional parameters.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_gettempname">SysUtils.GetTempName</a></div></td>
<td class="hintcell">
<p class="definition">sTempFileName = SysUtils.GetTempName()</p>
<p>Will return a filename to use as a temporary filename (in the system directory for the temporary files), similar to the <a href="#libraryos">os.tmpname</a> function, but the file will be created in a subdirectory that is automatically deleted when Double Commander is closed.<br>If the function could not create a unique name, it will return an empty string.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="sysutils_pathdelim">SysUtils.PathDelim</a></div></td>
<td class="hintcell">
<p class="definition">SysUtils.PathDelim</p>
<p>The character used by the current operating system to separate directory names in the full file name.</p>
<p>In Unix/Linux system the directory separator will be "/" and in Windows it will be "\".</p>
</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="detailattr">3.2.1. Details on SysUtils.FileGetAttr returned value</a></h2>
<p><code>FileGetAttr</code> returns the attribute settings of file <var>sFileName</var>.</p>
<p>The attribute is a <var>OR</var>-ed combination of the following constants:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Constants uses in SysUtils.FileGetAttr returned value</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Value</th><th class="categorydesccolumn">Signification</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000001<br><small class="firstcolumnaleft">faReadOnly</small></div></td>
<td class="hintcell">The file is read-only.</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000002<br><small class="firstcolumnaleft">faHidden</small></div></td>
<td class="hintcell">The file is hidden.<br>In Unix/Linux, this means that the filename starts with a dot.</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000004<br><small class="firstcolumnaleft">faSysFile</small></div></td>
<td class="hintcell">The file is a system file.<br>In Unix/Linux, this means that the file is a character or block device, a named pipe (FIFO).</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000008<br><small class="firstcolumnaleft">faVolumeId</small></div></td>
<td class="hintcell">Volume Label.<br>Only for DOS/Windows on a plain FAT (not VFAT or FAT32) filesystem.</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000010<br><small class="firstcolumnaleft">faDirectory</small></div></td>
<td class="hintcell">File is a directory.</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000020<br><small class="firstcolumnaleft">faArchive</small></div></td>
<td class="hintcell">File is archived.<br>Not possible in Unix/Linux.</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft">0x00000400<br><small class="firstcolumnaleft">faSymLink</small></div></td>
<td class="hintcell">File is a symbolic link.</td>
</tr>
<tr>
<td colspan="2"><b>Note: In case of an error, -1 is returned.</b>
</tr>
</table>
<p>See an example in the <a href="#exampleattr">next section</a>.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="exampleattr">3.2.2. Example with SysUtils.FileGetAttr</a></h2>
<p>This following script is an example of usage of the <code>SysUtils.FileGetAttr</code>.</p>
<p>When the parameter is detected to be a directory, it will open a new tab in the active panel and switch to it.</p>
<pre>
<span class="luakyw">local</span> params <span class="luasbl">=</span> <span class="luasbl">{...}</span>
<span class="luakyw">local</span> iAttr
<span class="luakyw">if</span> <span class="luasbl">#</span>params <span class="luasbl">==</span> <span class="luanum">1</span> <span class="luakyw">then</span> <span class="luacmt">-- We got at least one parameter?</span>
iAttr <span class="luasbl">=</span> <span class="mark">SysUtils.FileGetAttr</span><span class="luasbl">(</span>params<span class="luasbl">[</span><span class="luanum">1</span><span class="luasbl">])</span>
<span class="luakyw">if</span> iAttr <span class="luasbl">></span> <span class="luanum">0</span> <span class="luakyw">then</span> <span class="luacmt">-- We got a valid attribute?</span>
<span class="luakyw">if</span> math.floor<span class="luasbl">(</span>iAttr <span class="luasbl">/</span> <span class="luanum">0x00000010</span><span class="luasbl">)</span> <span class="luastr">%</span> <span class="luanum">2</span> <span class="luasbl">~=</span> <span class="luanum">0</span> <span class="luakyw">then</span>
<span class="luacmt">-- bit 4 is set? So it's a directory.</span>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">"cm_NewTab"</span><span class="luasbl">)</span>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">"cm_ChangeDir"</span><span class="luasbl">,</span> params<span class="luasbl">[</span><span class="luanum">1</span><span class="luasbl">])</span>
<span class="luakyw">end</span>
<span class="luakyw">end</span>
<span class="luakyw">end</span></pre>
<p>In the above example, the <var>params[1]</var> is the 1st parameter passed to the script.</p>
<p>When using the internal command <a href="cmds.html#cm_ExecuteScript">cm_ExecuteScript</a>, it will will be the first parameter passed after the script filename.</p>
<p>So in our example, we may program a sample toolbar button like the following:</p>
<p class="figure"><img class="largeimage" title="Parameter with cm_ExecuteScript" alt="Parameter with cm_ExecuteScript" src="images/imgDC/luaimg3.png" width="560" height="290"></p>
<p>In this example, the parameter <code>%"0%p</code> will be passed to the script. This will represent, unquoted, the filename of the item currently selected in the active panel at the moment we press the toolbar button.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="examplefind">3.2.3. Example using FindFirst, FindNext and FindClose</a></h2>
<p>In the following script example, we'll scan the content of the directory we received in parameter and store resulting data into a text file with the filename passed as a second parameter.</p>
<p>This will give us a good idea of the usage of <code>FindFirst</code>, <code>FindNext</code> and <code>FindClose</code>.</p>
<pre>
<span class="luakyw">local</span> params <span class="luasbl">=</span> <span class="luasbl">{...}</span>
<span class="luakyw">if</span> <span class="luasbl">#</span>params <span class="luasbl">==</span> <span class="luanum">2</span> <span class="luakyw">then</span> <span class="luacmt">-- We got our 2 parameters?</span>
<span class="luakyw">local</span> Result <span class="luasbl">=</span> <span class="luakyw">nil</span>
<span class="luacmt">local</span> hOutputFile <span class="luasbl">=</span> <span class="luakyw">nil</span>
hOutputFile <span class="luasbl">=</span> io.output(params<span class="luasbl">[</span><span class="luanum">2</span><span class="luasbl">])</span>
<span class="luakyw">local</span> Handle<span class="luasbl">,</span> FindData <span class="luasbl">=</span> <span class="mark">SysUtils.FindFirst</span><span class="luasbl">(</span>params<span class="luasbl">[</span><span class="luanum">1</span><span class="luasbl">]</span> <span class="luasbl">..</span> <span class="luastr">"\\*"</span><span class="luasbl">)</span>
<span class="luakyw">if</span> Handle <span class="luasbl">~=</span> <span class="luakyw">nil</span> <span class="luakyw">then</span>
<span class="luakyw">repeat</span>
io.write<span class="luasbl">(</span>FindData.Name <span class="luasbl">..</span> <span class="luastr">"\r"</span><span class="luasbl">)</span>
io.write<span class="luasbl">(</span>FindData.Size <span class="luasbl">..</span> <span class="luastr">"\r"</span><span class="luasbl">)</span>
io.write<span class="luasbl">(</span><span class="luastr">"---------------\r"</span><span class="luasbl">)</span>
Result<span class="luasbl">,</span> FindData <span class="luasbl">=</span> <span class="mark">SysUtils.FindNext</span><span class="luasbl">(</span>Handle<span class="luasbl">)</span>
<span class="luakyw">until</span> Result <span class="luasbl">==</span> <span class="luakyw">nil</span>
<span class="mark">SysUtils.FindClose</span><span class="luasbl">(</span>Handle<span class="luasbl">)</span>
io.close<span class="luasbl">(</span>hOutputFile<span class="luasbl">)</span>
<span class="luakyw">end</span>
<span class="luakyw">end</span></pre>
<p>In the above example, we need to pass two parameters to our script:</p>
<ol>
<li><var>params[1]</var> - which is the directory we want the content</li>
<li><var>params[2]</var> - which is the outputfilename to store the result</li>
</ol>
<p>So it's easy to configure a toolbar button using the internal command <a href="cmds.html#cm_ExecuteScript">cm_ExecuteScript</a> and pass the parameter to accomplish all this.</p>
<p class="figure"><img class="largeimage" title="Parameter with cm_ExecuteScript" alt="Parameter with cm_ExecuteScript" src="images/imgDC/luaimg4.png" width="560" height="262"></p>
<p>In this example, the parameter <code>%"0%Ds</code> will be passed to the script as the first parameter. This will represent, unquoted, the directory displayed by the active panel.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="libraryclip">3.3. Clipboard library</a></h2>
<p>Double Commander may provide external clipboard functionality to our Lua scripts.</p>
<p>Following table gives us the related functions:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Clipboard library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="clipbrd_clear">Clipbrd.Clear</a></div></td>
<td class="hintcell">
<p class="definition">Clipbrd.Clear()</p>
<p>Clear the content of the clipboard.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="clipbrd_getastext">Clipbrd.GetAsText</a></div></td>
<td class="hintcell">
<p class="definition">sVar = Clipbrd.GetAsText()</p>
<p>Get the current text content of the clipboard to assigned it to <var>sVar</var>. If the clipboard does not contain text, the function returns an empty string.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="clipbrd_setastext">Clipbrd.SetAsText</a></div></td>
<td class="hintcell">
<p class="definition">Clipbrd.SetAsText(sVar)</p>
<p>Store in the clipboard the text content of <var>sVar</var>.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="clipbrd_setashtml">Clipbrd.SetAsHtml</a></div></td>
<td class="hintcell">
<p class="definition">Clipbrd.SetAsHtml(sHtml)</p>
<p>Adds html-formatted text <var>sHtml</var> to the clipboard (<code>CF_HTML</code> clipboard format).</p>
<p>This contents will be inserted in applications which support this clipboard format, like MS Word, LO Writer, etc.</p>
<p>It's correct to store data with both <code>Clipbrd.SetAsText</code> and <code>Clipbrd.SetAsHtml</code>. When we'll paste, the application will use the best one that it supports.</p>
<p>For example we may have this:</p>
<ul>
<li><code>Clipbrd.SetAsText("Welcome to Double Commander!")</code></li>
<li><code>Clipbrd.SetAsHtml("Welcome to <b>Double Commander</b>!")</code></li>
</ul>
<p>If we switch to Notepad attempting to paste something, it will paste in plain text the message we copied with <code>Clipbrd.SetAsText</code>. But if we switch to Microsoft Word and paste something, it will paste the second one, the one with <b>Double Commander</b> in bold since the Microsoft Word recognize and support that clipboard content type.</p>
</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="exampleclip">3.3.1. Example of usage clipboard library</a></h2>
<p>The following example is using three functions related with the clipboard: <code>Clear</code>, <code>GetAsText</code> and <code>SetAsText</code>.</p>
<p>It's a relative long script but it's good to put together a few functions we've seen above.</p>
<p>It assumes our active panel is currently into a directory with many source text files.</p>
<p>It also assumes we currently have in clipboard a single word and that it will receive as a single parameter the current active folder.</p>
<p>The script will scan the file in that current level of directory and will read the content of them one by one to detect text line that contains the word that was in clipboard.</p>
<p>Then, the filenames of the files that contain at least one line with that word will be place into the clipboard.</p>
<p>Then, the script will use the internal command <a href="cmds.html#cm_LoadSelectionFromClip">cm_LoadSelectionFromClip</a> and the files that have the words will then be selected.</p>
<p>Also, at the end, we put back in our clipboard the original word that needed to be searched.</p>
<pre>
<span class="luakyw">local</span> params <span class="luasbl">=</span> <span class="luasbl">{...}</span>
<span class="luakyw">local</span> Result <span class="luasbl">=</span> <span class="luakyw">nil</span>
<span class="luakyw">local</span> iAttr
<span class="luakyw">local</span> bFound <span class="luasbl">=</span> <span class="luakyw">false</span>
<span class="luakyw">local</span> sCompleteFilename <span class="luasbl">=</span> <span class="luastr">""</span>
<span class="luakyw">local</span> hInputFile <span class="luasbl">=</span> <span class="luakyw">nil</span>
<span class="luakyw">local</span> sLine <span class="luasbl">=</span> <span class="luastr">""</span>
<span class="luakyw">local</span> iPosS
<span class="luakyw">local</span> iPosE
<span class="luakyw">local</span> sFileToSelect <span class="luasbl">=</span> <span class="luastr">""</span>
<span class="luakyw">local</span> sSearchString <span class="luasbl">=</span> <span class="luastr">""</span>
<span class="luakyw">if</span> <span class="luasbl">#</span>params <span class="luasbl">==</span> <span class="luanum">1</span> <span class="luakyw">then</span> <span class="luacmt">-- We got our parameter?</span>
sSearchString <span class="luasbl">=</span> <span class="mark">Clipbrd.GetAsText</span><span class="luasbl">()</span> <span class="luacmt">-- Get the expression to search.</span>
<span class="mark">Clipbrd.Clear</span><span class="luasbl">()</span> <span class="luacmt">-- Making sure we have nothing in clipboard.</span>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">"cm_MarkUnmarkAll"</span><span class="luasbl">)</span> <span class="luacmt">-- Make sure nothing is selected.</span>
<span class="luacmt">-- Let's scan one by one all the files of our directory.</span>
<span class="luakyw">local</span> Handle<span class="luasbl">,</span> FindData <span class="luasbl">=</span> SysUtils.FindFirst<span class="luasbl">(</span>params<span class="luasbl">[</span><span class="luanum">1</span><span class="luasbl">]</span> <span class="luasbl">..</span> <span class="luastr">"\\*"</span><span class="luasbl">)</span>
<span class="luakyw">if</span> Handle <span class="luasbl">~=</span> <span class="luakyw">nil</span> <span class="luakyw">then</span>
<span class="luakyw">repeat</span>
sCompleteFilename <span class="luasbl">=</span> params<span class="luasbl">[</span><span class="luanum">1</span><span class="luasbl">]</span> <span class="luasbl">..</span> <span class="luastr">"\\"</span> <span class="luasbl">..</span> FindData.Name
iAttr <span class="luasbl">=</span> SysUtils.FileGetAttr<span class="luasbl">(</span>sCompleteFilename<span class="luasbl">)</span>
<span class="luakyw">if</span> iAttr > <span class="luanum">0</span> <span class="luakyw">then</span> <span class="luacmt">-- We got a valid attribute?</span>
<span class="luacmt">-- We need file, not directory!</span>
<span class="luakyw">if</span> math.floor<span class="luasbl">(</span>iAttr <span class="luasbl">/</span> <span class="luanum">0x00000010</span><span class="luasbl">)</span> <span class="luasbl">%</span> <span class="luanum">2</span> <span class="luasbl">==</span> <span class="luanum">0</span> <span class="luakyw">then</span>
<span class="luacmt">-- Let's now read the file line by line until the the end OR a found.</span>
hInputFile <span class="luasbl">=</span> io.open<span class="luasbl">(</span>sCompleteFilename<span class="luasbl">,</span> <span class="luastr">"r"</span><span class="luasbl">)</span>
bFound <span class="luasbl">=</span> <span class="luakyw">false</span>
<span class="luakyw">while</span> bFound <span class="luasbl">==</span> <span class="luakyw">false</span> <span class="luakyw">do</span>
sLine <span class="luasbl">=</span> hInputFile:read<span class="luasbl">()</span>
<span class="luakyw">if</span> sLine <span class="luasbl">==</span> <span class="luakyw">nil</span> <span class="luakyw">then</span> <span class="luakyw">break</span> <span class="luakyw">end</span>
iPosS<span class="luasbl">,</span> iPosE <span class="luasbl">=</span> string.find<span class="luasbl">(</span>sLine<span class="luasbl">,</span> sSearchString<span class="luasbl">)</span>
<span class="luakyw">if</span> iPosS <span class="luasbl">~=</span> <span class="luakyw">nil</span> <span class="luakyw">then</span> bFound <span class="luasbl">=</span> <span class="luakyw">true</span> <span class="luakyw">end</span>
<span class="luakyw">end</span>
<span class="luakyw">if</span> bFound <span class="luasbl">==</span> <span class="luakyw">true</span> <span class="luakyw">then</span>
sFileToSelect <span class="luasbl">=</span> sFileToSelect <span class="luasbl">..</span> FindData.Name <span class="luasbl">..</span> <span class="luastr">"\n"</span>
<span class="luakyw">end</span>
io.close<span class="luasbl">(</span>hInputFile<span class="luasbl">)</span>
<span class="luakyw">end</span>
<span class="luakyw">end</span>
Result<span class="luasbl">,</span> FindData <span class="luasbl">=</span> SysUtils.FindNext<span class="luasbl">(</span>Handle<span class="luasbl">)</span>
<span class="luakyw">until</span> Result <span class="luasbl">==</span> <span class="luakyw">nil</span>
SysUtils.FindClose<span class="luasbl">(</span>Handle<span class="luasbl">)</span>
<span class="luakyw">end</span>
<span class="luacmt">-- If we've found something, select it!</span>
<span class="luakyw">if</span> sFileToSelect <span class="luasbl">~=</span> <span class="luastr">""</span> <span class="luakyw">then</span>
<span class="mark">Clipbrd.SetAsText</span><span class="luasbl">(</span>sFileToSelect<span class="luasbl">)</span>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">"cm_LoadSelectionFromClip"</span><span class="luasbl">)</span>
<span class="luakyw">end</span>
<span class="mark">Clipbrd.SetAsText</span><span class="luasbl">(</span>sSearchString<span class="luasbl">)</span> <span class="luacmt">-- Restoring what we had in clipboard.</span>
<span class="luakyw">end</span></pre>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="librarydialogs">3.4. Dialogs library</a></h2>
<p>This library allows our scripts to interact with user to display message, prompt for answers, etc.</p>
<p>Following table gives us the related functions:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Dialogs library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="dialogs_messagebox">Dialogs.MessageBox</a></div></td>
<td class="hintcell">
<p class="definition">iButton = Dialogs.MessageBox(sMessage, sTitle, iFlags)</p>
<p>Will display a message box prompting a user to click a button which will be returned by the function:</p>
<ul>
<li><var>sMessage</var> : The message inside the box.</li>
<li><var>sTitle</var> : The text displayed as the title of the box.</li>
<li><var>iFlags</var> : OR'ed value of constants to determine the buttons that will be displayed, the style of window and default button selected for the answer. See the following table the <a href="#dlgbuts">buttons displayed</a>, <a href="#dlgstyle">style of window</a> or <a href="#dlgdefbut">default button</a>.</li>
<li><var>iButton</var> : Returned value indicating the button user pressed (see <a href="#msgreturn">this table</a>).</li>
</ul>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="dialogs_inputquery">Dialogs.InputQuery</a></div></td>
<td class="hintcell">
<p class="definition">bResult, sAnswer = Dialogs.InputQuery(sTitle, sMessage, bMask, sDefault)</p>
<p>Will display a requester box where user may enter a string value:</p>
<ul>
<li><var>sTitle</var> : The text displayed as the title of the box.</li>
<li><var>sMessage</var> : The message inside the box.</li>
<li><var>bMask</var> : A boolean, when true, will display "stars" to hide characters.</li>
<li><var>sDefault</var> : The default suggested text that user may type over if necessary.</li>
<li><var>bResult</var> : Returned boolean indicating if user effectively enter something or not.</li>
<li><var>sAnswer</var> : Returned string when user entered something and then clicked ok.</li>
</ul>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="dialogs_inputlistbox">Dialogs.InputListBox</a></div></td>
<td class="hintcell">
<p class="definition">sItem, iItem = Dialogs.InputListBox(sTitle, sMessage, aItems, sDefault)</p>
<p>Displays a dialog box to allow the user to choose from a list of items:</p>
<ul>
<li><var>sTitle</var> : The text displayed as the title of the dialog.</li>
<li><var>sMessage</var> : The message inside the dialog.</li>
<li><var>aItems</var> : A Lua table, each element of the table must be a string.</li>
<li><var>sDefault</var> : The default selected item in the list.</li>
<li><var>sItem</var> : Returned the selected item as a string or <code>nil</code> if the dialog is dismissed.</li>
<li><var>iItem</var> : Index of the selected item (counting from one, as is customary in Lua tables).</li>
</ul>
</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="dlgbuts">3.4.1. Buttons displayed in Dialogs.MessageBox</a></h2>
<p>The buttons displayed in the box displayed by <code>Dialogs.MessageBox</code> function are controlled by a OR'ed value with one of the following:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Constant of ButFlags regarding the buttons displayed of Dialogs.MessageBox</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Constant value</th><th class="categorydesccolumn">Buttons displayed, from left to right</th></tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0000<br><small class="firstcolumnaleft">MB_OK</small></div></td>
<td class="hintcell">
<img class="largeimage" title="Button OK" alt="Button OK" src="images/imgDC/luaimg11.png" width="66" height="21">
</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0001<br><small class="firstcolumnaleft">MB_OKCANCEL</small></div></td>
<td class="hintcell">
<img class="largeimage" title="Button OK" alt="Button OK" src="images/imgDC/luaimg11.png" width="66" height="21">
<img class="largeimage" title="Button CANCEL" alt="Button CANCEL" src="images/imgDC/luaimg12.png" width="66" height="21">
</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0002<br><small class="firstcolumnaleft">MB_ABORTRETRYIGNORE</small></div></td>
<td class="hintcell">
<img class="largeimage" title="Button ABORT" alt="Button ABORT" src="images/imgDC/luaimg15.png" width="66" height="21">
<img class="largeimage" title="Button RETRY" alt="Button RETRY" src="images/imgDC/luaimg14.png" width="66" height="21">
<img class="largeimage" title="Button IGNORE" alt="Button IGNORE" src="images/imgDC/luaimg13.png" width="66" height="21">
</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0003<br><small class="firstcolumnaleft">MB_YESNOCANCEL</small></div></td>
<td class="hintcell">
<img class="largeimage" title="Button YES" alt="Button YES" src="images/imgDC/luaimg16.png" width="66" height="21">
<img class="largeimage" title="Button NO" alt="Button NO" src="images/imgDC/luaimg17.png" width="66" height="21">
<img class="largeimage" title="Button CANCEL" alt="Button CANCEL" src="images/imgDC/luaimg12.png" width="66" height="21">
</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0004<br><small class="firstcolumnaleft">MB_YESNO</small></div></td>
<td class="hintcell">
<img class="largeimage" title="Button YES" alt="Button YES" src="images/imgDC/luaimg16.png" width="66" height="21">
<img class="largeimage" title="Button NO" alt="Button NO" src="images/imgDC/luaimg17.png" width="66" height="21">
</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0005<br><small class="firstcolumnaleft">MB_RETRYCANCEL</small></div></td>
<td class="hintcell">
<img class="largeimage" title="Button RETRY" alt="Button RETRY" src="images/imgDC/luaimg14.png" width="66" height="21">
<img class="largeimage" title="Button CANCEL" alt="Button CANCEL" src="images/imgDC/luaimg12.png" width="66" height="21">
</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="dlgstyle">3.4.2. Style of box of Dialogs.MessageBox</a></h2>
<p>The style of the box displayed by <code>Dialogs.MessageBox</code> function are controlled by a OR'ed value with one of the following:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Constant of ButFlags regarding the icon and style of Dialogs.MessageBox</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Constant value</th><th class="categorydesccolumn">Style of window</th></tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0040<br><small class="firstcolumnaleft">MB_ICONINFORMATION</small></div></td>
<td class="hintcell"><img class="largeimage" title="Icon INFORMATION" alt="Icon INFORMATION" src="images/imgDC/luaimg8.png" width="32" height="32"> Informative window</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0030<br><small class="firstcolumnaleft">MB_ICONWARNING</small></div></td>
<td class="hintcell"><img class="largeimage" title="Icon WARNING" alt="Icon WARNING" src="images/imgDC/luaimg9.png" width="32" height="32"> Warning window</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0020<br><small class="firstcolumnaleft">MB_ICONQUESTION</small></div></td>
<td class="hintcell"><img class="largeimage" title="Icon QUESTION" alt="Icon QUESTION" src="images/imgDC/luaimg7.png" width="32" height="32"> Confirmation window</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0010<br><small class="firstcolumnaleft">MB_ICONERROR</small></div></td>
<td class="hintcell"><img class="largeimage" title="Icon ERROR" alt="Icon ERROR" src="images/imgDC/luaimg10.png" width="32" height="32"> Error window</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="dlgdefbut">3.4.3. Default active button of Dialogs.MessageBox</a></h2>
<p>The default active button of the box displayed by <code>Dialogs.MessageBox</code> function are controlled by a OR'ed value with one of the following:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Constant of ButFlags regarding the default button of Dialogs.MessageBox</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Constant value</th><th class="categorydesccolumn">Default button</th></tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0000<br><small class="firstcolumnaleft">MB_DEFBUTTON1</small></div></td>
<td class="hintcell">Default will be the first one on left</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0100<br><small class="firstcolumnaleft">MB_DEFBUTTON2</small></div></td>
<td class="hintcell">Default will be the second one from left</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0200<br><small class="firstcolumnaleft">MB_DEFBUTTON3</small></div></td>
<td class="hintcell">Default will be the third one from left</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="msgreturn">3.4.4. Returned value of Dialogs.MessageBox</a></h2>
<p>The number returned by the <code>Dialogs.MessageBox</code> function represent the button user has pressed according to the following:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">ButPressed value returned based on button pressed of Dialogs.MessageBox</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Constant value</th><th class="categorydesccolumn">Button pressed</th></tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0000<br><small class="firstcolumnaleft">mrNone</small></div></td>
<td class="hintcell">No button pressed</td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0001<br><small class="firstcolumnaleft">mrOK</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result OK" alt="Result OK" src="images/imgDC/luaimg11.png" width="66" height="21"></td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0002<br><small class="firstcolumnaleft">mrCancel</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result CANCEL" alt="Result CANCEL" src="images/imgDC/luaimg12.png" width="66" height="21"></td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0003<br><small class="firstcolumnaleft">mrAbort</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result ABORT" alt="Result ABORT" src="images/imgDC/luaimg15.png" width="66" height="21"></td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0004<br><small class="firstcolumnaleft">mrRetry</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result RETRY" alt="Result RETRY" src="images/imgDC/luaimg14.png" width="66" height="21"></td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0005<br><small class="firstcolumnaleft">mrIgnore</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result IGNORE" alt="Result IGNORE" src="images/imgDC/luaimg13.png" width="66" height="21"></td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0006<br><small class="firstcolumnaleft">mrYes</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result YES" alt="Result YES" src="images/imgDC/luaimg16.png" width="66" height="21"></td>
</tr>
<tr>
<td class="varcell"><div class="firstcolumnaleft">0x0007<br><small class="firstcolumnaleft">mrNo</small></div></td>
<td class="hintcell"><img class="largeimage" title="Result NO" alt="Result NO" src="images/imgDC/luaimg17.png" width="66" height="21"></td>
</tr>
</table>
<p>Note: If we press the "x" in top right or press <kbd>Esc</kbd> to close the window, then the value of the button "Cancel" is will returned.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="mesgboxsample">3.4.5. Example of usage of the Dialogs.MessageBox</a></h2>
<p>Here is a little script using <code>Dialogs.MessageBox</code> and the resulting window that will be displayed:</p>
<pre>
<span class="luacmt">-- Buttons displayed</span>
MB_OK <span class="luasbl">=</span> <span class="luanum">0x0000</span>
MB_OKCANCEL <span class="luasbl">=</span> <span class="luanum">0x0001</span>
MB_ABORTRETRYIGNORE <span class="luasbl">=</span> <span class="luanum">0x0002</span>
MB_YESNOCANCEL <span class="luasbl">=</span> <span class="luanum">0x0003</span>
MB_YESNO <span class="luasbl">=</span> <span class="luanum">0x0004</span>
MB_RETRYCANCEL <span class="luasbl">=</span> <span class="luanum">0x0005</span>
<span class="luacmt">-- Box style</span>
MB_ICONINFORMATION <span class="luasbl">=</span> <span class="luanum">0x0040</span>
MB_ICONWARNING <span class="luasbl">=</span> <span class="luanum">0x0030</span>
MB_ICONQUESTION <span class="luasbl">=</span> <span class="luanum">0x0020</span>
MB_ICONERROR <span class="luasbl">=</span> <span class="luanum">0x0010</span>
<span class="luacmt">-- Default button</span>
MB_DEFBUTTON1 <span class="luasbl">=</span> <span class="luanum">0x0000</span>
MB_DEFBUTTON2 <span class="luasbl">=</span> <span class="luanum">0x0100</span>
MB_DEFBUTTON3 <span class="luasbl">=</span> <span class="luanum">0x0200</span>
<span class="luacmt">-- Returned button pressed</span>
mrNone <span class="luasbl">=</span> <span class="luanum">0x0000</span>
mrOK <span class="luasbl">=</span> <span class="luanum">0x0001</span>
mrCancel <span class="luasbl">=</span> <span class="luanum">0x0002</span>
mrAbort <span class="luasbl">=</span> <span class="luanum">0x0003</span>
mrRetry <span class="luasbl">=</span> <span class="luanum">0x0004</span>
mrIgnore <span class="luasbl">=</span> <span class="luanum">0x0005</span>
mrYes <span class="luasbl">=</span> <span class="luanum">0x0006</span>
mrNo <span class="luasbl">=</span> <span class="luanum">0x0007</span>
iFlags <span class="luasbl">=</span> MB_YESNO <span class="luasbl">+</span> MB_ICONQUESTION <span class="luasbl">+</span> MB_DEFBUTTON2
iButton <span class="luasbl">=</span> <span class="mark">Dialogs.MessageBox</span><span class="luasbl">(</span><span class="luastr">"Do you want to quit?"</span><span class="luasbl">,</span> <span class="luastr">"Question"</span><span class="luasbl">,</span> iFlags<span class="luasbl">)</span>
<span class="luakyw">if</span> iButton <span class="luasbl">==</span> mrYes <span class="luakyw">then</span>
DC.ExecuteCommand<span class="luasbl">(</span><span class="luastr">"cm_Exit"</span><span class="luasbl">)</span>
<span class="luakyw">end</span></pre>
<p class="figure"><img class="largeimage" title="Example of usage of the Dialogs.MessageBox" alt="Example of usage of the Dialogs.MessageBox" src="images/imgDC/luaimg6.png" width="362" height="120"></p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="querysample">3.4.6. Example of usage of the Dialogs.InputQuery</a></h2>
<p>Here is a little script using <code>Dialogs.InputQuery</code> and the resulting window that will be displayed:</p>
<pre>
bResult<span class="luasbl">,</span> sAnswer <span class="luasbl">=</span> <span class="mark">Dialogs.InputQuery</span><span class="luasbl">(</span><span class="luastr">"Identification"</span><span class="luasbl">,</span> <span class="luastr">"Enter your name:"</span><span class="luasbl">,</span> <span class="luakyw">false</span><span class="luasbl">,</span> <span class="luastr">"John"</span><span class="luasbl">)</span>
<span class="luakyw">if</span> bResult <span class="luasbl">==</span> <span class="luakyw">true</span> <span class="luakyw">then</span>
Dialogs.MessageBox<span class="luasbl">(</span><span class="luastr">"Hello "</span> <span class="luasbl">..</span> sAnswer <span class="luasbl">..</span> <span class="luastr">"!"</span><span class="luasbl">,</span> <span class="luastr">"Welcome!"</span><span class="luasbl">,</span> <span class="luanum">0x0040</span><span class="luasbl">)</span>
<span class="luakyw">end</span></pre>
<p class="figure"><img class="largeimage" title="Example of usage of the Dialogs.InputQuery" alt="Example of usage of the Dialogs.InputQuery" src="images/imgDC/luaimg5.png" width="364" height="112"></p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="libraryutf8">3.5. UTF-8 library</a></h2>
<p>This library provides basic support for UTF-8 encoding.</p>
<p>It provides all its functions inside the table <code>LazUtf8</code>.</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">UTF-8 library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_pos">LazUtf8.Pos</a></div></td>
<td class="hintcell">
<p class="definition">iResult = LazUtf8.Pos(SearchText, SourceText, Offset)</p>
<p>Search for substring in a string, starting at a certain position. The search is case sensitive.</p>
<p>Returns the position of the first occurrence of the substring <var>SearchText</var> in the string <var>SourceText</var>, starting the search at position <var>Offset</var> (default 1).</p>
<p>If <var>SearchText</var> does not occur in <var>SourceText</var> after the given <var>Offset</var>, zero is returned.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_next">LazUtf8.Next</a></div></td>
<td class="hintcell">
<p class="definition">LazUtf8.Next(String)</p>
<p>An iterator function that, each time it is called, returns the next character in the <var>String</var> and the position of the beginning of this character (in bytes).</p>
<p>Example:</p>
<pre>
<span class="luacmt">-- Print pairs of values in the form "position : character"</span>
<span class="luakyw">for</span> iPos<span class="luasbl">,</span> sChar <span class="luakyw">in</span> <span class="mark">LazUtf8.Next</span><span class="luasbl">(</span>String<span class="luasbl">)</span> <span class="luakyw">do</span>
DC.LogWrite<span class="luasbl">(</span>iPos <span class="luasbl">..</span> <span class="luastr">" : "</span> <span class="luasbl">..</span> sChar<span class="luasbl">)</span>
<span class="luakyw">end</span></pre>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_copy">LazUtf8.Copy</a></div></td>
<td class="hintcell">
<p class="definition">sResult = LazUtf8.Copy(String, iIndex, iCount)</p>
<p>Copy part of a string.</p>
<p>Copy returns a string which is a copy if the <var>iCount</var> characters in <var>String</var>, starting at position <var>iIndex</var>.</p>
<p>If <var>iCount</var> is larger than the length of the string <var>String</var>, the result is truncated. If <var>iIndex</var> is larger than the length of the string <var>String</var>, then an empty string is returned.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_length">LazUtf8.Length</a></div></td>
<td class="hintcell">
<p class="definition">iResult = LazUtf8.Length(String)</p>
<p>Returns the number of UTF-8 characters in the string.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_uppercase">LazUtf8.UpperCase</a></div></td>
<td class="hintcell">
<p class="definition">sResult = LazUtf8.UpperCase(String)</p>
<p>Receives a string and returns a copy of this string with all lowercase letters changed to uppercase.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_lowercase">LazUtf8.LowerCase</a></div></td>
<td class="hintcell">
<p class="definition">sResult = LazUtf8.LowerCase(String)</p>
<p>Receives a string and returns a copy of this string with all uppercase letters changed to lowercase.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_convertencoding">LazUtf8.ConvertEncoding</a></div></td>
<td class="hintcell">
<p class="definition">sResult = LazUtf8.ConvertEncoding(String, FromEnc, ToEnc)</p>
<p>Convert <var>String</var> encoding from <var>FromEnc</var> to <var>ToEnc</var>.</p>
<p>List of supported encoding values:</p>
<ul>
<li>Default system encoding (depends on the system locale): "default".</li>
<li>Default ANSI (Windows) encoding (depends on the system locale): "ansi".</li>
<li>Default OEM (DOS) encoding (depends on the system locale): "oem".</li>
<li>Unicode: "utf8", "utf8bom", "ucs2le", "ucs2be".</li>
<li>ANSI (Windows): "cp1250", "cp1251", "cp1252", "cp1253", "cp1254", "cp1255", "cp1256", "cp1257", "cp1258".</li>
<li>OEM (DOS): "cp437", "cp850", "cp852", "cp866", "cp874", "cp932", "cp936", "cp949", "cp950".</li>
<li>ISO 8859: "iso88591", "iso88592", "iso885915".</li>
<li>Other: "macintosh", "koi8".</li>
</ul>
The meaning of special encodings (examples).
<br><br>
In Windows (English or Russian):
<ul>
<li>"default" - cp1252 or cp1251</li>
<li>"ansi" - cp1252 or cp1251</li>
<li>"oem" - cp850 or cp866</li>
</ul>
In Linux (English or Russian):
<ul>
<li>"default" - utf8</li>
<li>"ansi" - cp1252 or cp1251</li>
<li>"oem" - cp850 or cp866</li>
</ul>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="lazutf8_detectencoding">LazUtf8.DetectEncoding</a></div></td>
<td class="hintcell">
<p class="definition">sEnc = LazUtf8.DetectEncoding(String)</p>
<p>Returns the value of encoding of the transmitted text.<br>The list of supported encodings is similar to those used in the <code>LazUtf8.ConvertEncoding</code> function.</p>
</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="librarychar">3.6. Char library</a></h2>
<p>This library contains functions for checking whether a character belongs to a particular Unicode category, as well as getting the category of a character.</p>
<p>List of available functions in this library:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">Char library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="char_getunicodecategory">Char.GetUnicodeCategory</a></div></td>
<td class="hintcell">
<p class="definition">iResult = Char.GetUnicodeCategory(Character)</p>
<p>Returns the Unicode category of a character <code>Character</code>, one of the following values:</p>
<table class="innercmddesc">
<tr class="rowinnerdesc"><th class="innerdescheader">Value</th><th class="innerdescheader">Description</th>
<tr><td colspan="2"> Letter:</td></tr>
<tr><td class="innerdescvaluecell">0</td><td class="innerdescdesccell">Uppercase Letter (Lu)</td></tr>
<tr><td class="innerdescvaluecell">1</td><td class="innerdescdesccell">Lowercase Letter (Ll)</td></tr>
<tr><td class="innerdescvaluecell">2</td><td class="innerdescdesccell">Titlecase Letter (Lt)</td></tr>
<tr><td class="innerdescvaluecell">3</td><td class="innerdescdesccell">Modifier Letter (Lm)</td></tr>
<tr><td class="innerdescvaluecell">4</td><td class="innerdescdesccell">Other Letter (Lo)</td></tr>
<tr><td colspan="2"> Mark:</td></tr>
<tr><td class="innerdescvaluecell">5</td><td class="innerdescdesccell">Non-Spacing Mark (Mn)</td></tr>
<tr><td class="innerdescvaluecell">6</td><td class="innerdescdesccell">Spacing Combining Mark (Mc)</td></tr>
<tr><td class="innerdescvaluecell">7</td><td class="innerdescdesccell">Enclosing Mark (Me)</td></tr>
<tr><td colspan="2"> Number:</td></tr>
<tr><td class="innerdescvaluecell">8</td><td class="innerdescdesccell">Decimal Digit Number (Nd)</td></tr>
<tr><td class="innerdescvaluecell">9</td><td class="innerdescdesccell">Letter Number (Nl)</td></tr>
<tr><td class="innerdescvaluecell">10</td><td class="innerdescdesccell">Other Number (No)</td></tr>
<tr><td colspan="2"> Punctuation:</td></tr>
<tr><td class="innerdescvaluecell">11</td><td class="innerdescdesccell">Connector Punctuation (Pc)</td></tr>
<tr><td class="innerdescvaluecell">12</td><td class="innerdescdesccell">Dash Punctuation (Pd)</td></tr>
<tr><td class="innerdescvaluecell">13</td><td class="innerdescdesccell">Open Punctuation (Ps)</td></tr>
<tr><td class="innerdescvaluecell">14</td><td class="innerdescdesccell">Close Punctuation (Pe)</td></tr>
<tr><td class="innerdescvaluecell">15</td><td class="innerdescdesccell">Initial Punctuation (Pi)</td></tr>
<tr><td class="innerdescvaluecell">16</td><td class="innerdescdesccell">Final Punctuation (Pf)</td></tr>
<tr><td class="innerdescvaluecell">17</td><td class="innerdescdesccell">Other Punctuation (Po)</td></tr>
<tr><td colspan="2"> Symbol:</td></tr>
<tr><td class="innerdescvaluecell">18</td><td class="innerdescdesccell">Math Symbol (Sm)</td></tr>
<tr><td class="innerdescvaluecell">19</td><td class="innerdescdesccell">Currency Symbol (Sc)</td></tr>
<tr><td class="innerdescvaluecell">20</td><td class="innerdescdesccell">Modifier Symbol (Sk)</td></tr>
<tr><td class="innerdescvaluecell">21</td><td class="innerdescdesccell">Other Symbol (So)</td></tr>
<tr><td colspan="2"> Separator:</td></tr>
<tr><td class="innerdescvaluecell">22</td><td class="innerdescdesccell">Space Separator (Zs)</td></tr>
<tr><td class="innerdescvaluecell">23</td><td class="innerdescdesccell">Line Separator (Zl)</td></tr>
<tr><td class="innerdescvaluecell">24</td><td class="innerdescdesccell">Paragraph Separator (Zp)</td></tr>
<tr><td colspan="2"> Other:</td></tr>
<tr><td class="innerdescvaluecell">25</td><td class="innerdescdesccell">Control (Cc)</td></tr>
<tr><td class="innerdescvaluecell">26</td><td class="innerdescdesccell">Format (Cf)</td></tr>
<tr><td class="innerdescvaluecell">27</td><td class="innerdescdesccell">Surrogate (Cs)</td></tr>
<tr><td class="innerdescvaluecell">28</td><td class="innerdescdesccell">Private Use (Co)</td></tr>
<tr><td class="innerdescvaluecell">29</td><td class="innerdescdesccell">Unassigned (Cn)</td></tr>
</table>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="char_isdigit">Char.IsDigit</a></div></td>
<td class="hintcell">
<p class="definition">bResult = Char.IsDigit(Character)</p>
<p>Returns <code>true</code> if the <var>Character</var> character is in the <i>Nd</i> category.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="char_isletter">Char.IsLetter</a></div></td>
<td class="hintcell">
<p class="definition">bResult = Char.IsLetter(Character)</p>
<p>Returns <code>true</code> if the <var>Character</var> character is in the category <i>Lu</i>, <i>Ll</i>, <i>Lt</i>, <i>Lm</i> or <i>Lo</i>.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="char_isletterordigit">Char.IsLetterOrDigit</a></div></td>
<td class="hintcell">
<p class="definition">bResult = Char.IsLetterOrDigit(Character)</p>
<p>Returns <code>true</code> if the <var>Character</var> character is in the category <i>Lu</i>, <i>Ll</i>, <i>Lt</i>, <i>Lm</i> <i>Lo</i>, <i>Nd</i> или <i>Nl</i>.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="char_islower">Char.IsLower</a></div></td>
<td class="hintcell">
<p class="definition">bResult = Char.IsLower(Character)</p>
<p>Returns <code>true</code> if the <var>Character</var> character is in the <i>Ll</i> category.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="char_isupper">Char.IsUpper</a></div></td>
<td class="hintcell">
<p class="definition">bResult = Char.IsUpper(Character)</p>
<p>Returns <code>true</code> if the <var>Character</var> character is in the <i>Lu</i> category.</p>
</td>
</tr>
</table>
<p>Also, these functions support working with two parameters: instead of a single character, we can specify a string and the position of the character in this string.</p>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="libraryos">3.7. OS library</a></h2>
<p>This library contains functions related with the operating system where Double Commander is running.</p>
<p>Here is the list of available functions in this library:</p>
<table>
<tr class="rowcategorytitle"><th colspan="2">OS library</th></tr>
<tr class="rowsubtitle"><th class="categorynamecolumn">Function name</th><th class="categorydesccolumn">Description</th></tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_execute">os.execute</a></div></td>
<td class="hintcell">
<p class="definition">iResultCode = os.execute(sCommand)</p>
<p>Will execute <var>sCommand</var> as it would be typed on the command-line and return the result code of the operation.</p>
<p>The <var>sCommand</var> could either be:</p>
<ul>
<li>A terminal command like <code>os.execute("dir > all.txt")</code></li>
<li>An executable like <code>os.execute("C:\\Windows\\System32\\calc.exe")</code></li>
<li>An executable with parameters:<br><code>os.execute("C:\\Utils\\fsum.exe -md5 test.bin > md5.txt")</code></li>
</ul>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_tmpname">os.tmpname</a></div></td>
<td class="hintcell">
<p class="definition">sTempFileName = os.tmpname()</p>
<p>Will return a filename to use as a temporary filename (in the system directory for the temporary files).<br>If the function could not create a unique name, it will return an empty string.</p>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_remove">os.remove</a></div></td>
<td class="hintcell">
<p class="definition">bResult, sError, iError = os.remove(sFileName)</p>
<p>Will delete the file or the directory with the name <var>sFileName</var>.</p>
<p>If it works, function returns <code>true</code>.</p>
<p>If it fails, function returns three things:</p>
<ol>
<li><code>nil</code> to indicate it failed</li>
<li><var>sError</var> for the error message description</li>
<li><var>iError</var> for the error code number</li>
</ol>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_rename">os.rename</a></div></td>
<td class="hintcell">
<p class="definition">bResult, sError, iError = os.rename(sOldName, sNewName)</p>
<p>Will rename the file <var>sOldName</var> with the new name <var>sNewName</var>.</p>
<p><b><span class="uline">Note:</span> If a file named <var>sNewName</var> already exists, it will be replaced!</b></p>
<p>If it works, function returns <code>true</code>.</p>
<p>If it fails, function returns three things:</p>
<ol>
<li><code>nil</code> to indicate it failed</li>
<li><var>sError</var> for the error message description</li>
<li><var>iError</var> for the error code number</li>
</ol>
</td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_getenv">os.getenv</a></div></td>
<td class="hintcell">
<p class="definition">Value = os.getenv(VariableName)</p>
<p>Will return the <var>Value</var> of the variable <var>VariableName</var> passed in parameter.<br>If no variable of that name exists, it will return <code>nil</code>.</p></td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_setenv">os.setenv</a></div></td>
<td class="hintcell">
<p class="definition">os.setenv(VariableName, Value)</p>
<p>Add or change the <var>VariableName</var> environment variable. In case of an error, the function returns -1.</p></td>
</tr>
<tr>
<td class="cmdcell"><div class="firstcolumnaleft"><a name="os_unsetenv">os.unsetenv</a></div></td>
<td class="hintcell">
<p class="definition">os.unsetenv(VariableName)</p>
<p>Remove the <var>VariableName</var> environment variable. In case of an error, the function returns -1.</p></td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
</div>
<div>
<h2><a name="index">4. Index</a></h2>
<table class="index">
<tr>
<td class="indexcell">
<p><span class="bold"><a href="#libdc">DC library</a></span></p>
<p>
<a href="#dc_currentpanel">DC.CurrentPanel</a><br>
<a href="#dc_executecommand">DC.ExecuteCommand</a><br>
<a href="#dc_logwrite">DC.LogWrite</a>
</p>
<br>
<p><span class="bold"><a href="#librarysystem">System library</a></span></p>
<p>
<a href="#sysutils_createdirectory">SysUtils.CreateDirectory</a><br>
<a href="#sysutils_createhardlink">SysUtils.CreateHardLink</a><br>
<a href="#sysutils_createsymboliclink">SysUtils.CreateSymbolicLink</a><br>
<a href="#sysutils_directoryexists">SysUtils.DirectoryExists</a><br>
<a href="#sysutils_extractfiledir">SysUtils.ExtractFileDir</a><br>
<a href="#sysutils_extractfiledrive">SysUtils.ExtractFileDrive</a><br>
<a href="#sysutils_extractfileext">SysUtils.ExtractFileExt</a><br>
<a href="#sysutils_extractfilename">SysUtils.ExtractFileName</a><br>
<a href="#sysutils_extractfilepath">SysUtils.ExtractFilePath</a><br>
<a href="#sysutils_fileexists">SysUtils.FileExists</a><br>
<a href="#sysutils_filegetattr">SysUtils.FileGetAttr</a><br>
<a href="#sysutils_findclose">SysUtils.FindClose</a><br>
<a href="#sysutils_findfirst">SysUtils.FindFirst</a><br>
<a href="#sysutils_findnext">SysUtils.FindNext</a><br>
<a href="#sysutils_getabsolutepath">SysUtils.GetAbsolutePath</a><br>
<a href="#sysutils_getrelativepath">SysUtils.GetRelativePath</a><br>
<a href="#sysutils_gettempname">SysUtils.GetTempName</a><br>
<a href="#sysutils_gettickcount">SysUtils.GetTickCount</a><br>
<a href="#sysutils_matchesmask">SysUtils.MatchesMask</a><br>
<a href="#sysutils_matchesmasklist">SysUtils.MatchesMaskList</a><br>
<a href="#sysutils_pathdelim">SysUtils.PathDelim</a><br>
<a href="#sysutils_readsymboliclink">SysUtils.ReadSymbolicLink</a><br>
<a href="#sysutils_sleep">SysUtils.Sleep</a>
</p>
<br>
</td>
<td class="indexcell">
<p><span class="bold"><a href="#libraryclip">Clipboard library</a></span></p>
<p>
<a href="#clipbrd_clear">Clipbrd.Clear</a><br>
<a href="#clipbrd_getastext">Clipbrd.GetAsText</a><br>
<a href="#clipbrd_setashtml">Clipbrd.SetAsHtml</a><br>
<a href="#clipbrd_setastext">Clipbrd.SetAsText</a>
</p>
<br>
<p><span class="bold"><a href="#librarydialogs">Dialogs library</a></span></p>
<p>
<a href="#dialogs_inputlistbox">Dialogs.InputListBox</a><br>
<a href="#dialogs_inputquery">Dialogs.InputQuery</a><br>
<a href="#dialogs_messagebox">Dialogs.MessageBox</a>
</p>
<br>
<p><span class="bold"><a href="#libraryutf8">UTF-8 library</a></span></p>
<p>
<a href="#lazutf8_convertencoding">LazUtf8.ConvertEncoding</a><br>
<a href="#lazutf8_copy">LazUtf8.Copy</a><br>
<a href="#lazutf8_detectencoding">LazUtf8.DetectEncoding</a><br>
<a href="#lazutf8_length">LazUtf8.Length</a><br>
<a href="#lazutf8_lowercase">LazUtf8.LowerCase</a><br>
<a href="#lazutf8_next">LazUtf8.Next</a><br>
<a href="#lazutf8_pos">LazUtf8.Pos</a><br>
<a href="#lazutf8_uppercase">LazUtf8.UpperCase</a>
</p>
<br>
<p><span class="bold"><a href="#librarychar">Char library</a></span></p>
<p>
<a href="#char_getunicodecategory">Char.GetUnicodeCategory</a><br>
<a href="#char_isdigit">Char.IsDigit</a><br>
<a href="#char_isletter">Char.IsLetter</a><br>
<a href="#char_isletterordigit">Char.IsLetterOrDigit</a><br>
<a href="#char_islower">Char.IsLower</a><br>
<a href="#char_isupper">Char.IsUpper</a>
</p>
<br>
</td>
<td class="indexcell">
<p><span class="bold"><a href="#libraryos">OS library</a></span></p>
<p>
<a href="#os_execute">os.execute</a><br>
<a href="#os_getenv">os.getenv</a><br>
<a href="#os_remove">os.remove</a><br>
<a href="#os_rename">os.rename</a><br>
<a href="#os_setenv">os.setenv</a><br>
<a href="#os_tmpname">os.tmpname</a><br>
<a href="#os_unsetenv">os.unsetenv</a>
</p>
</td>
</tr>
</table>
<p class="navback"><a href="#topofpage">(back to top)</a></p>
<br>
</div>
</div>
<div class="footer"><div class="nav"><a title="Index" href="index.html">Index</a> | <a title="Previous page" href="regexp.html">Previous</a> | <a title="Next page" href="commandline.html">Next</a></div></div>
<div class="checker">
<a href="https://validator.w3.org/check?uri=referer" target="_blank"><img src="https://www.w3.org/Icons/valid-html40" alt="Valid HTML 4.0 Transitional" height="31" width="88"></a>
<a href="https://jigsaw.w3.org/css-validator/check/referer" target="_blank"><img style="border:0;width:88px;height:31px" src="https://jigsaw.w3.org/css-validator/images/vcss" alt="CSS Valid!"></a>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>
|