Getting started on Windows machines
Author(s): Manuel Hermenegildo.
This part guides you through some very basic first steps with Ciao on an MSWindows (“Win32”) system. It assumes that Ciao is already installed correctly on your Windows system. If this is not the case, then follow the instructions in Installing Ciao from a Win32 binary distribution (or Installing Ciao from the source distribution) first.
We start with by describing the basics of using Ciao from the Windows explorer and/or a DOS command shell. We strongly recommend reading also An introduction to the Ciao emacs environment (Win32) for the basics on using Ciao under emacs, which is a much simpler and much more powerful way of developing Ciao programs, and has the advantage of offering an almost identical environment under Windows and Un*x.
Testing your Ciao Win32 installation
It is a good idea to start by performing some tests to check that Ciao is installed correctly on your system (these are the same tests that you are instructed to do during installation, so you can obviously skip them if you have done them already at that time):
- Ciao-related file types (.pl source files, .cpx executables, .itf,.po,.asr interface files, .pls scripts, etc.) should have specific icons associated with them (you can look at the files in the folders in the Ciao distribution to check).
- Double-clicking on the shortcut to ciaosh(.cpx) on the desktop should start the typical Prolog-style top-level shell in a window. If this shortcut has not been created on the desktop, then double-clicking on the ciaosh(.cpx) icon inside the shell folder within the Ciao source folder should have the same effect.
- In the top-level shell, Ciao library modules should load correctly. Type for example use_module(library(dec10_io)). at the Ciao top-level prompt --you should get back a prompt with no errors reported.
- To exit the top level shell, type halt. as usual, or ^D.
Also, the following documentation-related actions should work:
- Double-clicking on the shortcut to ciao(.html) which appears on the desktop should show the Ciao manual in your default WWW browser. If this shortcut has not been created you can double-click on the ciao(.html) file in the doc\reference\ciao_html folder inside the Ciao source folder. Make sure you configure your browser to use style sheets for correct formatting of the manual (note, however, that some older versions of Explorer did not support style sheets well and will give better results turning them off).
- The doc\reference folder contains the manual also in the other formats present in the distribution, such as info (very convenient for users of the emacs editor/program development system) and postscript or pdf, which are specially useful for printing. See Printing manuals (Win32) for instructions.
Using Ciao from the Windows explorer and command shell
Starting/exiting the top-level shell (Win32)
The basic methods for starting/exiting the top-level shell have been discussed above. The installation script also leaves a ciaosh(.bat) file inside the shell folder of the Ciao distribution which can be used to start the top-level shell from the command line in Windows systems.
Getting help (Win32)
The basic methods for accessing the manual on-line have also been discussed above. Use the table of contents and the indices of predicates, libraries, concepts, etc. to find what you are looking for. Context-sensitive help is available within the emacs environment (see below).
Compiling and running programs (Win32)
Once the shell is started, you can compile and execute Ciao modules inside the interactive toplevel shell in the standard way. E.g., type use_module(file)., use_module(library(file)). for library modules, ensure_loaded(file). for files which are not modules, and use_package(file). for library packages (these are syntactic/semantic packages that extend the Ciao language in many different ways). Note that the use of compile/1 and consult/1 is discouraged in Ciao.
For example, you may want to type use_package(iso) to ensure Ciao has loaded all the ISO builtins (whether this is done by default or not depends on your .ciaorc file). Do not worry about any “module already in executable” messages --these are normal and simply mean that a certain module is already pre-loaded in the toplevel shell. At this point, typing write(hello). should work.
Note that some predicates that may be built-ins in typical Prolog implementations are available through libraries in Ciao. This facilitates making small executables.
To change the working directory to, say, the examples directory in the Ciao source directory, first do:
?- use_module(library(system)).
(loading the system library makes a number of system-related predicates such as cd/1 accessible) and then:
?- cd('$/examples').
(in Ciao the sequence $/ at the beginning of a path name is replaced by the path of the Ciao root directory).
For more information see The interactive top-level shell.
Generating executables (Win32)
Executables can be generated from the toplevel shell (using make_exec/2) or using the standalone compiler (ciaoc(.cpx), located in the ciaoc folder). To be able to make an executable, the file should define the predicate main/1 (or main/0), which will be called upon startup (see the corresponding manual section for details).
For example, within the examples directory, you can type:
?- make_exec(hw,_).
which should produce an executable. Double-clicking on this executable should execute it.
Another way of creating Ciao executables from source files is by right-clicking on .pl files and choosing “make executable”. This uses the standalone compiler (this has the disadvantage, however, that it is sometimes difficult to see the error messages).
For more information see The interactive top-level shell and The stand-alone command-line compiler.
Running Ciao scripts (Win32)
Double-clicking on files ending in .pls, Ciao scripts, will also execute them. These are files containing Ciao source but which get executed without having to explicitly compile them (in the same way as, e.g., .bat files or programs in scripting languages). As an example, you can double-click on the file hw.pls in the examples folder and look at the source with an editor. You can try changing the Hello world message and double-clicking again (no need to recompile!).
As you can see, the file should define the predicate main/1 (not main/0), which will be called upon startup. The two header lines are only necessary in Un*x. In Windows you can leave them in or you can take them out, but leaving them in has the advantage that the script will also work in Un*x without any change.
For more information see The script interpreter.
The Ciao initialization file (Win32)
The Ciao toplevel can be made to execute upon startup a number of commands (such as, e.g., loading certain files or setting certain Ciao flags) contained in an initialization file. This file should be called .ciaorc and placed in your home folder (e.g., the same in which the .emacs file is put). You may need to set the environment variable HOME to the path of this folder for the Ciao toplevel shell to be able to locate this file on startup.
Printing manuals (Win32)
As mentioned before, the manual is available in several formats in the reference folder within Ciao's doc folder, including postscript or pdf, which are specially useful for printing. This can be done using an application such as ghostview (freely available from http://www.cs.wisc.edu/~ghost/index.html) or acrobat reader (http://www.adobe.com, only pdf).
An introduction to the Ciao emacs environment (Win32)
While it is easy to use Ciao with any editor of your choice, using it within the emacs editor/program development system is highly recommended: Ciao includes an emacs mode which provides a very complete application development environment which greatly simplifies many program development tasks. See Using Ciao inside GNU emacs for details on the capabilities of ciao/emacs combination.
If the (freely available) emacs editor/environment is not installed in your system, we highly recommend that you also install it at this point (there are instructions for where to find emacs and how to install it in the Ciao installation instructions). After having done this you can try for example the following things:
- A few basic things:
- Typing ^H i (or in the menus Help->Manuals->Browse Manuals with Info) should open a list of manuals in info format in which the Ciao manual(s) should appear.
- When opening a Ciao file, i.e., a file with .pl or .pls ending, using ^X^Ffilename (or using the menus) the code should appear highlighted according to syntax (e.g., comments in red), and Ciao/Prolog menus should appear in the menu bar on top of the emacs window.
- Loading the file using the Ciao/Prolog menu (or typing ^C l) should start in another emacs buffer the Ciao toplevel shell and load the file. You should now be able to switch the the toplevel shell and make queries from within emacs.
Note: when using emacs it is very convenient to swap the locations of the (normally not very useful) Caps Lock key and the (very useful in emacs) Ctrl key on the keyboard. How to do this is explained in the emacs frequently asked questions FAQs (see the emacs download instructions for their location).
(if these things do not work the system or emacs may not be installed properly).
- You can go to the location of most of the errors that may be reported during compilation by typing ^C `.
- You can also, e.g., create executables from the Ciao/Prolog menu, as well as compile individual files, or generate active modules.
- Loading a file for source-level debugging using the Ciao/Prolog menu (or typing ^C d) and then issuing a query should start the source-level debugger and move a marker on the code in a window while execution is stepped through in the window running the Ciao top level.
- You can add the lines needed in Un*x for turning any file defining main/1 into a script from the Ciao/Prolog menu or by typing ^C I S.
- You can also work with the preprocessor and auto-documenter directly from emacs: see their manuals or browse through the corresponding menus that appear when editing .pl files.
We encourage you once more to read Using Ciao inside GNU emacs to discover the many other functionalities of this environment.
Keeping up to date (Win32)
You may want to read Beyond installation for instructions on how to sign up on the Ciao user's mailing list, receive announcements regarding new versions, download new versions, report bugs, etc.