home *** CD-ROM | disk | FTP | other *** search
- PDC Prolog Questions and Answers
-
- QUESTION
- What side effects are created by Prolog's type conversions between
- real, integer and char domains?
-
- ANSWER
- The Prolog type checker automatically allows conversions between
- character, integer and reals.
-
- This is normally a nice feature, but in some cases it can give
- unexpected results if one is not aware of this feature.
-
- The basic example of the problem can be illustrated by the
- following code:
-
- PREDICATES
- p(INTEGER,INTEGER)
- p(REAL,REAL)
-
- CLAUSES
- p(X,Y):-Y=X+1.
-
- GOAL p(1.5,Z), write(Z). % Z will be bound to 2
-
- The problem here is that the type checker in the goal will try the
- first declaration of p first, and in this instance it will find that
- 1.5 is compatible with an integer.
-
- This problem will most often appear in external goals because
- there are no type restrictions on the variables. The problem is
- rarely seen in real programs because the variables will normally
- be bound to the desired type by other calls. (The solution to the
- above problem is to have only the declaration for reals, since
- this can handle both domains correctly.)
-
- The problem can be somewhat annoying, but it is in most cases harmless,
- and it can easily be avoided.
-
-
- QUESTION
- How do I correctly return an errorlevel value using system/3 under DOS?
-
- ANSWER
- System/3 will return the correct value for the DOS errorlevel
- only if the filename passed to the predicate has an .EXE or
- .COM extension.
-
- If a file name is given without an extension, it might be a .BAT
- file, and for .BAT files the command interpreter has to be
- invoked. The problem is that the DOS command interpreter does not
- return a proper errorlevel.
-
- Ex.
-
- system("prog",1,RetCode)
-
- Will make a call to: "COMMAND.COM prog", but
-
- system("prog.exe",1,RetCode)
-
- will make a call to: "prog.exe"
-
-
- QUESTION
- What about Turbo Debugger with .EXE files created by PDC Prolog?
-
- ANSWER
- C modules linked to PDC Prolog can be debugged with Turbo
- Debugger. Just compile and link the modules with symbolic
- information. (Use the -v option for the Turbo C compiler and /v
- for the Turbo C linker).
-
-
- QUESTION
- What about mouse support?
-
- ANSWER
- The PDC Prolog Toolbox has predicates for a mouse interface for
- both text mode and graphics mode.
-
- The integrated environment currently has no mouse support.
-
- There is currently no mouse support in the OS/2 version, but with
- a simple C module this is very easy to implement.
-
-
- QUESTION
- What about graphics support in OS/2?
-
- ANSWER
- At the moment there is no direct graphics support in the form of
- system predicates. But we are using Presentation Manager quite a
- bit at PDC, and we will soon provide links to PM.
-
-
- QUESTION
- How do I convert external databases from Turbo Prolog to PDC Prolog?
-
- ANSWER
- The procedure is:
-
- 1) Write a program in Turbo Prolog 2.0 that exports the external
- database to a text file.
-
- 2) Write a program in PDC Prolog 3.2 that imports the text file
- to a new external database file.
-
- See the PDC Prolog User's Guide, page 356, or the Turbo Prolog
- User's Guide, page 348, for the required procedure.
-