home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 1.ddi / Q&A.DOC < prev    next >
Encoding:
Text File  |  1990-03-26  |  3.2 KB  |  112 lines

  1. PDC Prolog Questions and Answers
  2.  
  3. QUESTION 
  4.  What side effects are created by Prolog's type conversions between 
  5.  real, integer and char domains?
  6.  
  7. ANSWER
  8.  The Prolog type checker automatically allows conversions between
  9.  character, integer and reals.
  10.  
  11.  This is normally a nice feature, but in some cases it can give
  12.  unexpected results if one is not aware of this feature.
  13.  
  14.  The basic example of the problem can be illustrated by the
  15.  following code:
  16.  
  17.  PREDICATES
  18.     p(INTEGER,INTEGER)
  19.     p(REAL,REAL)
  20.  
  21.  CLAUSES
  22.     p(X,Y):-Y=X+1.
  23.  
  24.  GOAL p(1.5,Z), write(Z).  % Z will be bound to 2
  25.  
  26.  The problem here is that the type checker in the goal will try the
  27.  first declaration of p first, and in this instance it will find that 
  28.  1.5 is compatible with an integer.
  29.  
  30.  This problem will most often appear in external goals because
  31.  there are no type restrictions on the variables. The problem is
  32.  rarely seen in real programs because the variables will normally
  33.  be bound to the desired type by other calls. (The solution to the 
  34.  above problem is to have only the declaration for reals, since 
  35.  this can handle both domains correctly.)
  36.  
  37.  The problem can be somewhat annoying, but it is in most cases harmless, 
  38.  and it can easily be avoided.
  39.  
  40.  
  41. QUESTION
  42.  How do I correctly return an errorlevel value using system/3 under DOS?
  43.  
  44. ANSWER
  45.  System/3 will return the correct value for the DOS errorlevel
  46.  only if the filename passed to the predicate has an .EXE or 
  47.  .COM extension.
  48.  
  49.  If a file name is given without an extension, it might be a .BAT
  50.  file, and for .BAT files the command interpreter has to be
  51.  invoked. The problem is that the DOS command interpreter does not
  52.  return a proper errorlevel.
  53.  
  54.  Ex.
  55.  
  56.    system("prog",1,RetCode)
  57.  
  58.  Will make a call to: "COMMAND.COM prog", but
  59.  
  60.    system("prog.exe",1,RetCode)
  61.  
  62. will make a call to: "prog.exe"
  63.  
  64.  
  65. QUESTION
  66.  What about Turbo Debugger with .EXE files created by PDC Prolog?
  67.  
  68. ANSWER
  69.  C modules linked to PDC Prolog can be debugged with Turbo
  70.  Debugger. Just compile and link the modules with symbolic
  71.  information.  (Use the -v option for the Turbo C compiler and /v
  72.  for the Turbo C linker).
  73.  
  74.  
  75. QUESTION
  76.  What about mouse support?
  77.  
  78. ANSWER
  79.  The PDC Prolog Toolbox has predicates for a mouse interface for
  80.  both text mode and graphics mode.
  81.  
  82.  The integrated environment currently has no mouse support.
  83.  
  84.  There is currently no mouse support in the OS/2 version, but with
  85.  a simple C module this is very easy to implement.
  86.  
  87.  
  88. QUESTION 
  89.  What about graphics support in OS/2?
  90.  
  91. ANSWER
  92.  At the moment there is no direct graphics support in the form of
  93.  system predicates. But we are using Presentation Manager quite a 
  94.  bit at PDC, and we will soon provide links to PM.
  95.  
  96.  
  97. QUESTION 
  98.  How do I convert external databases from Turbo Prolog to PDC Prolog?
  99.  
  100. ANSWER
  101.  The procedure is:
  102.  
  103.  1) Write a program in Turbo Prolog 2.0 that exports the external
  104.  database to a text file.
  105.  
  106.  2) Write a program in PDC Prolog 3.2 that imports the text file
  107.  to a new external database file.
  108.  
  109.  See the PDC Prolog User's Guide, page 356, or the Turbo Prolog
  110.  User's Guide, page 348, for the required procedure.
  111.  
  112.