/usr/lib/swi-prolog/doc/Manual/system.html is in swi-prolog-nox 6.6.4-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>SWI-Prolog 7.1.10 Reference Manual: Section 4.34</title><link rel="home" href="index.html">
<link rel="contents" href="Contents.html">
<link rel="index" href="DocIndex.html">
<link rel="summary" href="summary.html">
<link rel="previous" href="tty.html">
<link rel="next" href="files.html">
<style type="text/css">
/* Style sheet for SWI-Prolog latex2html
*/
dd.defbody
{ margin-bottom: 1em;
}
dt.pubdef, dt.multidef
{ color: #fff;
padding: 2px 10px 0px 10px;
margin-bottom: 5px;
font-size: 18px;
vertical-align: middle;
overflow: hidden;
}
dt.pubdef { background-color: #0c3d6e; }
dt.multidef { background-color: #ef9439; }
.bib dd
{ margin-bottom: 1em;
}
.bib dt
{ float: left;
margin-right: 1.3ex;
}
pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}
div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}
div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}
div.author
{ text-align: center;
font-style: italic;
}
div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}
div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}
div.toc-h1
{ font-size: 200%;
font-weight: bold;
}
div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}
div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}
div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}
span.sec-nr
{
}
span.sec-title
{
}
span.pred-ext
{ font-weight: bold;
}
span.pred-tag
{ float: right;
padding-top: 0.2em;
font-size: 80%;
font-style: italic;
color: #fff;
}
div.caption
{ width: 80%;
margin: auto;
text-align:center;
}
/* Footnotes */
.fn {
color: red;
font-size: 70%;
}
.fn-text, .fnp {
position: absolute;
top: auto;
left: 10%;
border: 1px solid #000;
box-shadow: 5px 5px 5px #888;
display: none;
background: #fff;
color: #000;
margin-top: 25px;
padding: 8px 12px;
font-size: larger;
}
sup:hover span.fn-text
{ display: block;
}
/* Lists */
dl.latex
{ margin-top: 1ex;
margin-bottom: 0.5ex;
}
dl.latex dl.latex dd.defbody
{ margin-bottom: 0.5ex;
}
/* PlDoc Tags */
dl.tags
{ font-size: 90%;
margin-left: 5ex;
margin-top: 1ex;
margin-bottom: 0.5ex;
}
dl.tags dt
{ margin-left: 0pt;
font-weight: bold;
}
dl.tags dd
{ margin-left: 3ex;
}
td.param
{ font-style: italic;
font-weight: bold;
}
/* Index */
dt.index-sep
{ font-weight: bold;
font-size: +1;
margin-top: 1ex;
}
/* Tables */
table.center
{ margin: auto;
}
table.latex
{ border-collapse:collapse;
}
table.latex tr
{ vertical-align: text-top;
}
table.latex td,th
{ padding: 2px 1em;
}
table.latex tr.hline td,th
{ border-top: 1px solid black;
}
table.frame-box
{ border: 2px solid black;
}
</style>
</head>
<body style="background:white">
<div class="navigate"><a class="nav" href="index.html"><img src="home.gif" alt="Home"></a>
<a class="nav" href="Contents.html"><img src="index.gif" alt="Contents"></a>
<a class="nav" href="DocIndex.html"><img src="yellow_pages.gif" alt="Index"></a>
<a class="nav" href="summary.html"><img src="info.gif" alt="Summary"></a>
<a class="nav" href="tty.html"><img src="prev.gif" alt="Previous"></a>
<a class="nav" href="files.html"><img src="next.gif" alt="Next"></a>
</div>
<h2 id="sec:system"><a id="sec:4.34"><span class="sec-nr">4.34</span> <span class="sec-title">Operating
System Interaction</span></a></h2>
<a id="sec:system"></a>
<dl class="latex">
<dt class="pubdef"><a id="shell/2"><strong>shell</strong>(<var>+Command,
-Status</var>)</a></dt>
<dd class="defbody">
Execute <var>Command</var> on the operating system. <var>Command</var>
is given to the Bourne shell (/bin/sh). <var>Status</var> is unified
with the exit status of the command.
<p>On Windows, <a id="idx:shell12:1246"></a><span class="pred-ext">shell/[1,2]</span>
executes the command using the CreateProcess() API and waits for the
command to terminate. If the command ends with a
<code>&</code> sign, the command is handed to the WinExec() API,
which does not wait for the new task to terminate. See also <a id="idx:winexec2:1247"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
and
<a id="idx:winshell2:1248"></a><a class="pred" href="system.html#win_shell/2">win_shell/2</a>.
Please note that the CreateProcess() API does <b>not</b> imply the
Windows command interpreter (<b>cmd.exe</b> and therefore commands that
are built in the command interpreter can only be activated using the
command interpreter. For example, a file can be compied using the
command below.
<pre class="code">
?- shell('cmd.exe /C copy file1.txt file2.txt').
</pre>
<p>Note that many of the operations that can be achieved using the shell
built-in commands can easily be achieved using Prolog primitives. See
<a id="idx:makedirectory1:1249"></a><a class="pred" href="files.html#make_directory/1">make_directory/1</a>, <a id="idx:deletefile1:1250"></a><a class="pred" href="files.html#delete_file/1">delete_file/1</a>, <a id="idx:renamefile2:1251"></a><a class="pred" href="files.html#rename_file/2">rename_file/2</a>,
etc. The clib package provides <code>library(filesex)</code>,
implementing various high level file operations such as <a id="idx:copyfile2:1252"></a><span class="pred-ext">copy_file/2</span>.
Using Prolog primitives instead of shell commands improves the
portability of your program.
<p>The library <code>library(process)</code> provides <a id="idx:processcreate3:1253"></a><span class="pred-ext">process_create/3</span>
and several related primitives that support more fine-grained
interaction with processes, including I/O redirection and management of
asynchronous processes.</dd>
<dt class="pubdef"><a id="shell/1"><strong>shell</strong>(<var>+Command</var>)</a></dt>
<dd class="defbody">
Equivalent to `<code>shell(Command, 0)</code>'.</dd>
<dt class="pubdef"><a id="shell/0"><strong>shell</strong></a></dt>
<dd class="defbody">
Start an interactive Unix shell. Default is <code>/bin/sh</code>; the
environment variable <code>SHELL</code> overrides this default. Not
available for Win32 platforms.</dd>
<dt class="pubdef"><a id="getenv/2"><strong>getenv</strong>(<var>+Name,
-Value</var>)</a></dt>
<dd class="defbody">
Get environment variable. Fails silently if the variable does not exist.
Please note that environment variable names are case-sensitive on Unix
systems and case-insensitive on Windows.</dd>
<dt class="pubdef"><a id="setenv/2"><strong>setenv</strong>(<var>+Name,
+Value</var>)</a></dt>
<dd class="defbody">
Set an environment variable. <var>Name</var> and <var>Value</var> must
be instantiated to atoms or integers. The environment variable will be
passed to <a id="idx:shell02:1254"></a><span class="pred-ext">shell/[0-2]</span>
and can be requested using <a id="idx:getenv2:1255"></a><a class="pred" href="system.html#getenv/2">getenv/2</a>.
They also influence <a id="idx:expandfilename2:1256"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>.
Environment variables are shared between threads. Depending on the
underlying C library, <a id="idx:setenv2:1257"></a><a class="pred" href="system.html#setenv/2">setenv/2</a>
and <a id="idx:unsetenv1:1258"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
may not be thread-safe and may cause memory leaks. Only changing the
environment once and before starting threads is safe in all versions of
SWI-Prolog.</dd>
<dt class="pubdef"><a id="unsetenv/1"><strong>unsetenv</strong>(<var>+Name</var>)</a></dt>
<dd class="defbody">
Remove an environment variable from the environment. Some systems lack
the underlying unsetenv() library function. On these systems <a id="idx:unsetenv1:1259"></a><a class="pred" href="system.html#unsetenv/1">unsetenv/1</a>
sets the variable to the empty string.</dd>
<dt class="pubdef"><a id="setlocale/3"><strong>setlocale</strong>(<var>+Category,
-Old, +New</var>)</a></dt>
<dd class="defbody">
Set/Query the <em>locale</em> setting which tells the C library how to
interpret text files, write numbers, dates, etc. Category is one of
<code>all</code>, <code>collate</code>, <code>ctype</code>, <code>messages</code>,
<code>monetary</code>, <code>numeric</code> or <code>time</code>. For
details, please consult the C library locale documentation. See also <a class="sec" href="widechars.html">section
2.18.1</a>. Please note that the locale is shared between all threads
and thread-safe usage of <a id="idx:setlocale3:1260"></a><a class="pred" href="system.html#setlocale/3">setlocale/3</a>
is in general not possible. Do locale operations before starting threads
or thoroughly study threading aspects of locale support in your
environment before using in multithreaded environments. Locale settings
are used by <a id="idx:formattime3:1261"></a><a class="pred" href="system.html#format_time/3">format_time/3</a>, <a id="idx:collationkey2:1262"></a><a class="pred" href="chartype.html#collation_key/2">collation_key/2</a>
and <a id="idx:localesort2:1263"></a><a class="pred" href="chartype.html#locale_sort/2">locale_sort/2</a>.</dd>
<dt class="pubdef"><a id="unix/1"><strong>unix</strong>(<var>+Command</var>)</a></dt>
<dd class="defbody">
This predicate comes from the Quintus compatibility library and provides
a partial implementation thereof. It provides access to some operating
system features and unlike the name suggests, is not operating system
specific. Defined <var>Command</var>'s are below.
<dl class="latex">
<dt><strong>system</strong>(<var>+Command</var>)</dt>
<dd class="defbody">
Equivalent to calling <a id="idx:shell1:1264"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
Use for compatibility only.</dd>
<dt><strong>shell</strong>(<var>+Command</var>)</dt>
<dd class="defbody">
Equivalent to calling <a id="idx:shell1:1265"></a><a class="pred" href="system.html#shell/1">shell/1</a>.
Use for compatibility only.</dd>
<dt><strong>shell</strong></dt>
<dd class="defbody">
Equivalent to calling <a id="idx:shell0:1266"></a><a class="pred" href="system.html#shell/0">shell/0</a>.
Use for compatibility only.</dd>
<dt><strong>cd</strong></dt>
<dd class="defbody">
Equivalent to calling <a id="idx:workingdirectory2:1267"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>
to the expansion (see
<a id="idx:expandfilename2:1268"></a><a class="pred" href="files.html#expand_file_name/2">expand_file_name/2</a>)
of <code><code>~</code></code>. For compatibility only.</dd>
<dt><strong>cd</strong>(<var>+Directory</var>)</dt>
<dd class="defbody">
Equivalent to calling <a id="idx:workingdirectory2:1269"></a><a class="pred" href="files.html#working_directory/2">working_directory/2</a>.
Use for compatibility only.</dd>
<dt><strong>argv</strong>(<var>-Argv</var>)</dt>
<dd class="defbody">
Unify <var>Argv</var> with the list of command line arguments provided
to this Prolog run. Please note that Prolog system arguments and
application arguments are separated by <code>--</code>. Integer
arguments are passed as Prolog integers, float arguments and Prolog
floating point numbers and all other arguments as Prolog atoms. New
applications should use the Prolog flag <a class="flag" href="flags.html#flag:argv">argv</a>.
See also the Prolog flag
<a class="flag" href="flags.html#flag:argv">argv</a>.
<p>A stand-alone program could use the following skeleton to handle
command line arguments. See also <a class="sec" href="compilation.html">section
2.10.2.4</a>.
<pre class="code">
main :-
current_prolog_flag(argv, Argv),
append(_PrologArgs, [--|AppArgs], Argv), !,
main(AppArgs).
</pre>
<p></dd>
</dl>
</dd>
</dl>
<p><h3 id="sec:winsystem"><a id="sec:4.34.1"><span class="sec-nr">4.34.1</span> <span class="sec-title">Windows-specific
Operating System Interaction</span></a></h3>
<a id="sec:winsystem"></a>
<p>The predicates in this section are only available on the Windows
version of SWI-Prolog. Their use is discouraged if there are portably
alternatives. For example, <a id="idx:winexec2:1270"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
and <a id="idx:willshell2:1271"></a><span class="pred-ext">will_shell/2</span>
can often be replaced by the more portable <a id="idx:shell2:1272"></a><a class="pred" href="system.html#shell/2">shell/2</a>
or the more powerful
<a id="idx:processcreate3:1273"></a><span class="pred-ext">process_create/3</span>.
<dl class="latex">
<dt class="pubdef"><a id="win_exec/2"><strong>win_exec</strong>(<var>+Command,
+Show</var>)</a></dt>
<dd class="defbody">
Windows only. Spawns a Windows task without waiting for its completion. <var>Show</var>
is one of the Win32 <code>SW_*</code> constants written in lowercase
without the <code>SW_*</code>:
<code>hide</code>
<code>maximize</code>
<code>minimize</code>
<code>restore</code>
<code>show</code>
<code>showdefault</code>
<code>showmaximized</code>
<code>showminimized</code>
<code>showminnoactive</code>
<code>showna</code>
<code>shownoactive</code>
<code>shownormal</code>. In addition, <code>iconic</code> is a synonym
for <code>minimize</code> and
<code>normal</code> for <code>shownormal</code>.</dd>
<dt class="pubdef"><a id="win_shell/2"><strong>win_shell</strong>(<var>+Operation,
+File, +Show</var>)</a></dt>
<dd class="defbody">
Windows only. Opens the document <var>File</var> using the Windows shell
rules for doing so. <var>Operation</var> is one of <code>open</code>,
<code>print</code> or <code>explore</code> or another operation
registered with the shell for the given document type. On modern systems
it is also possible to pass a <a id="idx:URL:1274"></a>URL as <var>File</var>,
opening the URL in Windows default browser. This call interfaces to the
Win32 API ShellExecute(). The <var>Show</var> argument determines the
initial state of the opened window (if any). See <a id="idx:winexec2:1275"></a><a class="pred" href="system.html#win_exec/2">win_exec/2</a>
for defined values.</dd>
<dt class="pubdef"><a id="win_shell/2"><strong>win_shell</strong>(<var>+Operation,
+File</var>)</a></dt>
<dd class="defbody">
Same as <code>win_shell(Operation, File, normal)</code></dd>
<dt class="pubdef"><a id="win_registry_get_value/3"><strong>win_registry_get_value</strong>(<var>+Key,
+Name, -Value</var>)</a></dt>
<dd class="defbody">
Windows only. Fetches the value of a Windows registry key. <var>Key</var>
is an atom formed as a path name describing the desired registry key.
<var>Name</var> is the desired attribute name of the key. <var>Value</var>
is unified with the value. If the value is of type <code>DWORD</code>,
the value is returned as an integer. If the value is a string, it is
returned as a Prolog atom. Other types are currently not supported. The
default `root' is <code>HKEY_CURRENT_USER</code>. Other roots can be
specified explicitly as
<code>HKEY_CLASSES_ROOT</code>, <code>HKEY_CURRENT_USER</code>,
<code>HKEY_LOCAL_MACHINE</code> or <code>HKEY_USERS</code>. The example
below fetches the extension to use for Prolog files (see <code>README.TXT</code>
on the Windows version):
<pre class="code">
?- win_registry_get_value(
'HKEY_LOCAL_MACHINE/Software/SWI/Prolog',
fileExtension,
Ext).
Ext = pl
</pre>
</dd>
<dt class="pubdef"><a id="win_folder/2"><strong>win_folder</strong>(<var>?Name,
-Directory</var>)</a></dt>
<dd class="defbody">
True if <var>Name</var> is the Windows `CSIDL' of <var>Directory</var>.
If
<var>Name</var> is unbound, all known Windows special paths are
generated.
<var>Name</var> is the CSIDL after deleting the leading <code>CSIDL_</code>
and mapping the constant to lowercase. Check the Windows documentation
for the function SHGetSpecialFolderPath() for a description of the
defined constants. This example extracts the `My Documents' folder:
<pre class="code">
?- win_folder(personal, MyDocuments).
MyDocuments = 'C:/Documents and Settings/jan/My Documents'
</pre>
</dd>
<dt class="pubdef"><a id="win_add_dll_directory/1"><strong>win_add_dll_directory</strong>(<var>+AbsDir</var>)</a></dt>
<dd class="defbody">
This predicate adds a directory to the search path for dependent DLL
files. If possible, this is achieved with <a id="idx:winadddlldirectory2:1276"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
Otherwise, <code>%PATH%</code> is extended with the provided directory.
<var>AbsDir</var> may be specified in the Prolog canonical syntax. See
<a id="idx:prologtoosfilename2:1277"></a><a class="pred" href="files.html#prolog_to_os_filename/2">prolog_to_os_filename/2</a>.
Note that <a id="idx:useforeignlibrary1:1278"></a><a class="pred" href="foreignlink.html#use_foreign_library/1">use_foreign_library/1</a>
passes an absolute path to the DLL if the destination DLL can be located
from the specification using <a id="idx:absolutefilename3:1279"></a><a class="pred" href="files.html#absolute_file_name/3">absolute_file_name/3</a>.</dd>
<dt class="pubdef"><a id="win_add_dll_directory/2"><strong>win_add_dll_directory</strong>(<var>+AbsDir,
-Cookie</var>)</a></dt>
<dd class="defbody">
This predicate adds a directory to the search path for dependent DLL
files. If the call is successful it unifies <var>Cookie</var> with a
handle that must be passed to <a id="idx:winremovedlldirectory1:1280"></a><a class="pred" href="system.html#win_remove_dll_directory/1">win_remove_dll_directory/1</a>
to remove the directory from the search path. Error conditions:
<p>
<ul class="latex">
<li>This predicate is available in the Windows port of SWI-Prolog
starting from 6.3.8/6.2.6.
<li>This predicate <em>fails</em> if Windows does not yet support the
underlying primitives. These are available in recently patched Windows 7
systems and later.
<li>This predicate throws an acception if the provided path is invalid
or the underlying Windows API returns an error.
</ul>
<p>If <a id="idx:opensharedobject2:1281"></a><a class="pred" href="foreignlink.html#open_shared_object/2">open_shared_object/2</a>
is passed an <em>absolute</em> path to a DLL on a Windows installation
that supports AddDllDirectory() and friends,<sup class="fn">94<span class="fn-text">Windows 7
with up-to-date patches or Windows 8.</span></sup> SWI-Prolog uses
LoadLibraryEx() with the flags
<code>LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR</code> and
<code>LOAD_LIBRARY_SEARCH_DEFAULT_DIRS</code>. In this scenario,
directories from <code>%PATH%</code> and <em>not</em> searched.
Additional directories can be added using <a id="idx:winadddlldirectory2:1282"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.</dd>
<dt class="pubdef"><a id="win_remove_dll_directory/1"><strong>win_remove_dll_directory</strong>(<var>-Cookie</var>)</a></dt>
<dd class="defbody">
Remove a DLL search directory installed using <a id="idx:winadddlldirectory2:1283"></a><a class="pred" href="system.html#win_add_dll_directory/2">win_add_dll_directory/2</a>.
</dd>
</dl>
<p><h3 id="sec:timedate"><a id="sec:4.34.2"><span class="sec-nr">4.34.2</span> <span class="sec-title">Dealing
with time and date</span></a></h3>
<a id="sec:timedate"></a>
<p>Representing time in a computer system is surprisingly complicated.
There are a large number of time representations in use, and the correct
choice depends on factors such as compactness, resolution and desired
operations. Humans tend to think about time in hours, days, months,
years or centuries. Physicists think about time in seconds. But, a month
does not have a defined number of seconds. Even a day does not have a
defined number of seconds as sometimes a leap-second is introduced to
synchronise properly with our earth's rotation. At the same time,
resolution demands a range from better than pico-seconds to millions of
years. Finally, civilizations have a wide range of calendars. Although
there exist libraries dealing with most if this complexity, our desire
to keep Prolog clean and lean stops us from fully supporting these.
<p>For human-oriented tasks, time can be broken into years, months,
days, hours, minutes, seconds and a timezone. Physicists prefer to have
time in an arithmetic type representing seconds or fraction thereof, so
basic arithmetic deals with comparison and durations. An additional
advantage of the physicist's approach is that it requires much less
space. For these reasons, SWI-Prolog uses an arithmetic type as its
prime time representation.
<p>Many C libraries deal with time using fixed-point arithmetic, dealing
with a large but finite time interval at constant resolution. In our
opinion, using a floating point number is a more natural choice as we
can use a natural unit and the interface does not need to be changed if
a higher resolution is required in the future. Our unit of choice is the
second as it is the scientific unit.<sup class="fn">95<span class="fn-text">Using
Julian days is a choice made by the Eclipse team. As conversion to dates
is needed for a human readable notation of time and Julian days cannot
deal naturally with leap seconds, we decided for the second as our unit.</span></sup>
We have placed our origin at 1970-1-1T0:0:0Z for compatibility with the
POSIX notion of time as well as with older time support provided by
SWI-Prolog.
<p>Where older versions of SWI-Prolog relied on the POSIX conversion
functions, the current implementation uses
<a class="url" href="http://cr.yp.to/libtai.html">libtai</a> to realise
conversion between time-stamps and calendar dates for a period of 10
million years.
<p><h4 id="sec:dattimedata"><a id="sec:4.34.2.1"><span class="sec-nr">4.34.2.1</span> <span class="sec-title">Time
and date data structures</span></a></h4>
<a id="sec:dattimedata"></a>
<p>We use the following time representations
<dl class="latex">
<dt><b>TimeStamp</b></dt>
<dd class="defbody">
A TimeStamp is a floating point number expressing the time in seconds
since the Epoch at 1970-1-1.</dd>
<dt><strong>date</strong>(<var>Y,M,D,H,Mn,S,Off,TZ,DST</var>)</dt>
<dd class="defbody">
We call this term a <em>date-time</em> structure. The first 5 fields are
integers expressing the year, month (1..12), day (1..31), hour (0..23)
and minute (0..59). The <var>S</var> field holds the seconds as a
floating point number between 0.0 and 60.0. <var>Off</var> is an integer
representing the offset relative to UTC in seconds, where positive
values are west of Greenwich. If converted from local time (see <a id="idx:stampdatetime3:1284"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>),
<var>TZ</var> holds the name of the local timezone. If the timezone is
not known, <var>TZ</var> is the atom <code><code>-</code></code>. <var>DST</var>
is <code>true</code> if daylight saving time applies to the current
time, <code>false</code> if daylight saving time is relevant but not
effective, and <code><code>-</code></code> if unknown or the timezone
has no daylight saving time.</dd>
<dt><strong>date</strong>(<var>Y,M,D</var>)</dt>
<dd class="defbody">
Date using the same values as described above. Extracted using
<a id="idx:datetimevalue3:1285"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.</dd>
<dt><strong>time</strong>(<var>H,Mn,S</var>)</dt>
<dd class="defbody">
Time using the same values as described above. Extracted using
<a id="idx:datetimevalue3:1286"></a><a class="pred" href="system.html#date_time_value/3">date_time_value/3</a>.
</dd>
</dl>
<p><h4 id="sec:datimepreds"><a id="sec:4.34.2.2"><span class="sec-nr">4.34.2.2</span> <span class="sec-title">Time
and date predicates</span></a></h4>
<a id="sec:datimepreds"></a>
<dl class="latex">
<dt class="pubdef"><a id="get_time/1"><strong>get_time</strong>(<var>-TimeStamp</var>)</a></dt>
<dd class="defbody">
Return the current time as a <var>TimeStamp</var>. The granularity is
system-dependent. See <a class="sec" href="system.html">section 4.34.2.1</a>.</dd>
<dt class="pubdef"><a id="stamp_date_time/3"><strong>stamp_date_time</strong>(<var>+TimeStamp,
-DateTime, +TimeZone</var>)</a></dt>
<dd class="defbody">
Convert a <var>TimeStamp</var> to a <var>DateTime</var> in the given
timezone. See <a class="sec" href="system.html">section 4.34.2.1</a> for
details on the data types. <var>TimeZone</var> describes the timezone
for the conversion. It is one of <code>local</code> to extract the local
time, <code>'UTC'</code> to extract a UTC time or an integer describing
the seconds west of Greenwich.</dd>
<dt class="pubdef"><a id="date_time_stamp/2"><strong>date_time_stamp</strong>(<var>+DateTime,
-TimeStamp</var>)</a></dt>
<dd class="defbody">
Compute the timestamp from a date/9 term. Values for month, day, hour,
minute or second need not be normalized. This flexibility allows for
easy computation of the time at any given number of these units from a
given timestamp. Normalization can be achieved following this call with <a id="idx:stampdatetime3:1287"></a><a class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</a>.
This example computes the date 200 days after 2006-7-14:
<pre class="code">
?- date_time_stamp(date(2006,7,214,0,0,0,0,-,-), Stamp),
stamp_date_time(Stamp, D, 0),
date_time_value(date, D, Date).
Date = date(2007, 1, 30)
</pre>
<p>When computing a time stamp from a local time specification, the UTC
offset (arg 7), TZ (arg 8) and DST (arg 9) argument may
be left unbound and are unified with the proper information. The example
below, executed in Amsterdam, illustrates this behaviour. On the 25th of
March at 01:00, DST does not apply. At 02.00, the clock is advanced by
one hour and thus both 02:00 and 03:00 represent the same time stamp.
<pre class="code">
1 ?- date_time_stamp(date(2012,3,25,1,0,0,UTCOff,TZ,DST),
Stamp).
UTCOff = -3600,
TZ = 'CET',
DST = false,
Stamp = 1332633600.0.
2 ?- date_time_stamp(date(2012,3,25,2,0,0,UTCOff,TZ,DST),
Stamp).
UTCOff = -7200,
TZ = 'CEST',
DST = true,
Stamp = 1332637200.0.
3 ?- date_time_stamp(date(2012,3,25,3,0,0,UTCOff,TZ,DST),
Stamp).
UTCOff = -7200,
TZ = 'CEST',
DST = true,
Stamp = 1332637200.0.
</pre>
<p>Note that DST and offset calculation are based on the POSIX function
mktime(). If mktime() returns an error, a representation_error
<code>dst</code> is generated.</dd>
<dt class="pubdef"><a id="date_time_value/3"><strong>date_time_value</strong>(<var>?Key,
+DateTime, ?Value</var>)</a></dt>
<dd class="defbody">
Extract values from a date/9 term. Provided keys are:
<p><table class="latex frame-hsides center">
<tr><td><b>key</b></td><td><b>value </b></td></tr>
<tr class="hline"><td><code>year</code> </td><td>Calendar year as an
integer </td></tr>
<tr><td><code>month</code> </td><td>Calendar month as an integer 1..12 </td></tr>
<tr><td><code>day</code> </td><td>Calendar day as an integer 1..31 </td></tr>
<tr><td><code>hour</code> </td><td>Clock hour as an integer 0..23 </td></tr>
<tr><td><code>minute</code> </td><td>Clock minute as an integer 0..59 </td></tr>
<tr><td><code>second</code> </td><td>Clock second as a float 0.0..60.0 </td></tr>
<tr><td><code>utc_offset</code> </td><td>Offset to UTC in seconds
(positive is west) </td></tr>
<tr><td><code>time_zone</code> </td><td>Name of timezone; fails if
unknown </td></tr>
<tr><td><code>daylight_saving</code> </td><td>Bool <code>daylight_saving</code>true)
if dst is in effect </td></tr>
<tr><td><code>date</code> </td><td>Term <code>date(Y,M,D)</code> </td></tr>
<tr><td><code>time</code> </td><td>Term <code>time(H,M,S)</code> </td></tr>
</table>
</dd>
<dt class="pubdef"><a id="format_time/3"><strong>format_time</strong>(<var>+Out,
+Format, +StampOrDateTime</var>)</a></dt>
<dd class="defbody">
Modelled after POSIX strftime(), using GNU extensions. <var>Out</var> is
a destination as specified with <a id="idx:withoutputto2:1288"></a><a class="pred" href="IO.html#with_output_to/2">with_output_to/2</a>. <var>Format</var>
is an atom or string with the following conversions. Conversions start
with a tilde (%) character.<sup class="fn">96<span class="fn-text">Descriptions
taken from Linux Programmer's Manual</span></sup>
<var>StampOrDateTime</var> is either a numeric time-stamp, a term
<code>date(Y,M,D,H,M,S,O,TZ,DST)</code> or a term <code>date(Y,M,D)</code>.
<p>
<ul class="latex">
<li><code>a</code><br>
The abbreviated weekday name according to the current locale. Use
<a id="idx:formattime4:1289"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
for POSIX locale.
<li><code>A</code><br>
The full weekday name according to the current locale. Use
<a id="idx:formattime4:1290"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
for POSIX locale.
<li><code>b</code><br>
The abbreviated month name according to the current locale. Use
<a id="idx:formattime4:1291"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
for POSIX locale.
<li><code>B</code><br>
The full month name according to the current locale. Use
<a id="idx:formattime4:1292"></a><a class="pred" href="system.html#format_time/4">format_time/4</a>
for POSIX locale.
<li><code>c</code><br>
The preferred date and time representation for the current locale.
<li><code>C</code><br>
The century number (year/100) as a 2-digit integer.
<li><code>d</code><br>
The day of the month as a decimal number (range 01 to 31).
<li><code>D</code><br>
Equivalent to %m/%d/%y. (For Americans only. Americans should note that
in other countries %d/%m/%y is rather common. This means that in an
international context this format is ambiguous and should not be used.)
<li><code>e</code><br>
Like %d, the day of the month as a decimal number, but a leading zero is
replaced by a space.
<li><code>E</code><br>
Modifier. Not implemented.
<li><code>f</code><br>
Number of microseconds. The <code>f</code> can be prefixed by an integer
to print the desired number of digits. E.g., <code>%3f</code> prints
milliseconds. This format is not covered by any standard, but available
with different format specifiers in various incarnations of the
strftime() function.
<li><code>F</code><br>
Equivalent to %Y-%m-%d (the ISO 8601 date format).
<li><code>g</code><br>
Like %G, but without century, i.e., with a 2-digit year (00-99).
<li><code>G</code><br>
The ISO 8601 year with century as a decimal number. The 4-digit year
corresponding to the ISO week number (see %V). This has the same format
and value as %y, except that if the ISO week number belongs to the
previous or next year, that year is used instead.
<li><code>V</code><br>
The ISO 8601:1988 week number of the current year as a decimal number,
range 01 to 53, where week 1 is the first week that has at least 4 days
in the current year, and with Monday as the first day of the week. See
also %U and %W.
<li><code>h</code><br>
Equivalent to %b.
<li><code>H</code><br>
The hour as a decimal number using a 24-hour clock (range 00 to 23).
<li><code>I</code><br>
The hour as a decimal number using a 12-hour clock (range 01 to 12).
<li><code>j</code><br>
The day of the year as a decimal number (range 001 to 366).
<li><code>k</code><br>
The hour (24-hour clock) as a decimal number (range 0 to 23); single
digits are preceded by a blank. (See also %H.)
<li><code>l</code><br>
The hour (12-hour clock) as a decimal number (range 1 to 12); single
digits are preceded by a blank. (See also %I.)
<li><code>m</code><br>
The month as a decimal number (range 01 to 12).
<li><code>M</code><br>
The minute as a decimal number (range 00 to 59).
<li><code>n</code><br>
A newline character.
<li><code>O</code><br>
Modifier to select locale-specific output. Not implemented.
<li><code>p</code><br>
Either `AM' or `PM' according to the given time value, or the
corresponding strings for the current locale. Noon is treated as `pm'
and midnight as `am'.
<li><code>P</code><br>
Like %p but in lowercase: `am' or `pm' or a corresponding string for the
current locale.
<li><code>r</code><br>
The time in a.m. or p.m. notation. In the POSIX locale this is
equivalent to `%I:%M:%S %p'.
<li><code>R</code><br>
The time in 24-hour notation (%H:%M). For a version including the
seconds, see %T below.
<li><code>s</code><br>
The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00
UTC.
<li><code>S</code><br>
The second as a decimal number (range 00 to 60). (The range is up to 60
to allow for occasional leap seconds.)
<li><code>t</code><br>
A tab character.
<li><code>T</code><br>
The time in 24-hour notation (%H:%M:%S).
<li><code>u</code><br>
The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
<li><code>U</code><br>
The week number of the current year as a decimal number, range 00 to 53,
starting with the first Sunday as the first day of week 01. See also %V
and %W.
<li><code>w</code><br>
The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
<li><code>W</code><br>
The week number of the current year as a decimal number, range 00 to 53,
starting with the first Monday as the first day of week 01.
<li><code>x</code><br>
The preferred date representation for the current locale without the
time.
<li><code>X</code><br>
The preferred time representation for the current locale without the
date.
<li><code>y</code><br>
The year as a decimal number without a century (range 00 to 99).
<li><code>Y</code><br>
The year as a decimal number including the century.
<li><code>z</code><br>
The timezone as hour offset from GMT using the format HHmm. Required to
emit RFC822-conforming dates (using
<code>'%a, %d %b %Y %T %z'</code>). Our
implementation supports
<code>%:z</code>, which modifies the output to HH:mm as required by
XML-Schema. Note that both notations are valid in ISO 8601. The sequence <code>%:z</code>
is compatible to the GNU date(1) command.
<li><code>Z</code><br>
The timezone or name or abbreviation.
<li><code><code>+</code></code><br>
The date and time in date(1) format.
<li><code>%</code><br>
A literal `%' character.
</ul>
<p>The table below gives some format strings for popular time
representations. RFC1123 is used by HTTP. The full implementation of
<a id="idx:httptimestamp2:1293"></a><span class="pred-ext">http_timestamp/2</span>
as available from <code>library(http/http_header)</code> is here.
<pre class="code">
http_timestamp(Time, Atom) :-
stamp_date_time(Time, Date, 'UTC'),
format_time(atom(Atom),
'%a, %d %b %Y %T GMT',
Date, posix).
</pre>
<p><table class="latex frame-hsides center">
<tr><td><b>Standard</b> </td><td><b>Format string</b> </td></tr>
<tr class="hline"><td><b>xsd</b> </td><td><code>'%FT%T%:z'</code> </td></tr>
<tr><td><b>ISO8601</b> </td><td><code>'%FT%T%z'</code> </td></tr>
<tr><td><b>RFC822</b> </td><td><code>'%a, %d %b %Y %T %z'</code> </td></tr>
<tr><td><b>RFC1123</b> </td><td><code>'%a, %d %b %Y %T GMT'</code> </td></tr>
</table>
</dd>
<dt class="pubdef"><a id="format_time/4"><strong>format_time</strong>(<var>+Out,
+Format, +StampOrDateTime, +Locale</var>)</a></dt>
<dd class="defbody">
Format time given a specified <var>Locale</var>. This predicate is a
work-around for lacking proper portable and thread-safe time and locale
handling in current C libraries. In its current implementation the only
value allowed for <var>Locale</var> is <code>posix</code>, which
currently only modifies the behaviour of the <code>a</code>, <code>A</code>, <code>b</code>
and <code>B</code> format specifiers. The predicate is used to be able
to emit POSIX locale week and month names for emitting standardised
time-stamps such as RFC1123.</dd>
<dt class="pubdef"><a id="parse_time/2"><strong>parse_time</strong>(<var>+Text,
-Stamp</var>)</a></dt>
<dd class="defbody">
Same as <code>parse_time(Text, _Format, Stamp)</code>. See <a id="idx:parsetime3:1294"></a><a class="pred" href="system.html#parse_time/3">parse_time/3</a>.</dd>
<dt class="pubdef"><a id="parse_time/3"><strong>parse_time</strong>(<var>+Text,
?Format, -Stamp</var>)</a></dt>
<dd class="defbody">
Parse a textual time representation, producing a time-stamp. Supported
formats for <var>Text</var> are in the table below. If the format is
known, it may be given to reduce parse time and avoid ambiguities.
Otherwise,
<var>Format</var> is unified with the format encountered.
<p><table class="latex frame-box center">
<tr><td><b>Name</b></td><td><b>Example </b></td></tr>
<tr class="hline"><td>rfc_1123</td><td><code>Fri, 08 Dec 2006 15:29:44
GMT </code></td></tr>
<tr class="hline"><td>iso_8601</td><td><code>2006-12-08T17:29:44+02:00 </code></td></tr>
<tr><td></td><td><code>20061208T172944+0200 </code></td></tr>
<tr><td></td><td><code>2006-12-08T15:29Z </code></td></tr>
<tr><td></td><td><code>2006-12-08 </code></td></tr>
<tr><td></td><td><code>20061208 </code></td></tr>
<tr><td></td><td><code>2006-12 </code></td></tr>
<tr><td></td><td><code>2006-W49-5 </code></td></tr>
<tr><td></td><td><code>2006-342 </code></td></tr>
</table>
</dd>
<dt class="pubdef"><a id="day_of_the_week/2"><strong>day_of_the_week</strong>(<var>+Date,-DayOfTheWeek</var>)</a></dt>
<dd class="defbody">
Computes the day of the week for a given date.
<code><var>Date</var> = date(<var>Year</var>,<var>Month</var>,<var>Day</var>)</code>.
Days of the week are numbered from one to seven: Monday = 1, Tuesday =
2, ... , Sunday = 7.
</dd>
</dl>
<p><h3 id="sec:plwin"><a id="sec:4.34.3"><span class="sec-nr">4.34.3</span> <span class="sec-title">Controlling
the <b>swipl-win.exe</b> console window</span></a></h3>
<a id="sec:plwin"></a>
<p>The Windows executable <b>swipl-win.exe</b> console has a number of
predicates to control the appearance of the console. Being totally
non-portable, we do not advise using it for your own application, but
use XPCE or another portable GUI platform instead. We give the
predicates for reference here.
<dl class="latex">
<dt class="pubdef"><a id="window_title/2"><strong>window_title</strong>(<var>-Old,
+New</var>)</a></dt>
<dd class="defbody">
Unify <var>Old</var> with the title displayed in the console and change
the title to <var>New</var>.<sup class="fn">bug<span class="fn-text">This
predicate should have been called <code>win_window_title</code> for
consistent naming.</span></sup></dd>
<dt class="pubdef"><a id="win_window_pos/1"><strong>win_window_pos</strong>(<var>+ListOfOptions</var>)</a></dt>
<dd class="defbody">
Interface to the MS-Windows SetWindowPos() function, controlling size,
position and stacking order of the window. <var>ListOfOptions</var> is a
list that may hold any number of the terms below:
<dl class="latex">
<dt><strong>size</strong>(<var>W, H</var>)</dt>
<dd class="defbody">
Change the size of the window. <var>W</var> and <var>H</var> are
expressed in character units.
</dd>
<dt><strong>position</strong>(<var>X, Y</var>)</dt>
<dd class="defbody">
Change the top-left corner of the window. The values are expressed in
pixel units.
</dd>
<dt><strong>zorder</strong>(<var>ZOrder</var>)</dt>
<dd class="defbody">
Change the location in the window stacking order. Values are
<code>bottom</code>, <code>top</code>, <code>topmost</code> and <code>notopmost</code>.
<em>Topmost</em> windows are displayed above all other windows.
</dd>
<dt><strong>show</strong>(<var>Bool</var>)</dt>
<dd class="defbody">
If <code>true</code>, show the window, if <code>false</code> hide the
window.
</dd>
<dt><strong>activate</strong></dt>
<dd class="defbody">
If present, activate the window.
</dd>
</dl>
</dd>
<dt class="pubdef"><a id="win_has_menu/0"><strong>win_has_menu</strong></a></dt>
<dd class="defbody">
True if <a id="idx:wininsertmenu2:1295"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>
and <a id="idx:wininsertmenuitem4:1296"></a><a class="pred" href="system.html#win_insert_menu_item/4">win_insert_menu_item/4</a>
are present.</dd>
<dt class="pubdef"><a id="win_insert_menu/2"><strong>win_insert_menu</strong>(<var>+Label,
+Before</var>)</a></dt>
<dd class="defbody">
Insert a new entry (pulldown) in the menu. If the menu already contains
this entry, nothing is done. The <var>Label</var> is the label and,
using the Windows convention, a letter prefixed with <code>&</code>
is underlined and defines the associated accelerator key. <var>Before</var>
is the label before which this one must be inserted. Using <code><code>-</code></code>
adds the new entry at the end (right). For example, the call below adds
an <b>Application</b> entry just before the <b>Help</b> menu.
<pre class="code">
win_insert_menu('&Application', '&Help')
</pre>
</dd>
<dt class="pubdef"><a id="win_insert_menu_item/4"><strong>win_insert_menu_item</strong>(<var>+Pulldown,
+Label, +Before, :Goal</var>)</a></dt>
<dd class="defbody">
Add an item to the named <var>Pulldown</var> menu. <var>Label</var> and
<var>Before</var> are handled as in <a id="idx:wininsertmenu2:1297"></a><a class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</a>,
but the label <code><code>-</code></code> inserts a <em>separator</em>. <var>Goal</var>
is called if the user selects the item.
</dd>
</dl>
<p></body></html>
|