home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / FOREIGN / TC / PTEST.PRO < prev    next >
Encoding:
Prolog Source  |  1990-03-26  |  2.1 KB  |  92 lines

  1.  
  2. domains
  3.   file = textfile
  4.  
  5. global predicates
  6.   write_storage_left language c as "_write_storage_left"
  7.   write_double(real) - (i) language c as "_write_double"
  8.   write_string(string) - (i) language c as "_write_string"
  9.   test_for_keypressed language c as "_test_for_keypressed"
  10.   write_char(char) - (i) language c as "_write_char"
  11.   mk_prolog_file language c as "_mk_prolog_file"
  12.   wait(string)-(i) language c as "_wait"
  13.  
  14.   % This is defined in the C code
  15.   testproc language c as "_testproc"
  16.  
  17. PREDICATES
  18.  repwr(INTEGER)
  19.  
  20.  
  21. clauses
  22.   repwr(0):-!.
  23.   repwr(N):-
  24.     write('-'),
  25.     N1=N-1,
  26.     repwr(N1).
  27.  
  28.   wait(STR):-
  29.     nl,
  30.     str_len(STR,LEN),
  31.     REP=(80-LEN) div 2 -2,
  32.     repwr(REP),
  33.     write(' ',STR,' '),
  34.     repwr(REP),
  35.     readchar(_).
  36.  
  37.   write_storage_left :-
  38.     write("\nStorage dump from prolog code:"),
  39.     storage.
  40.  
  41.   write_double(D) :-
  42.     writef("\nWrite double = %", D).
  43.  
  44.   write_string(S) :-
  45.     write(S).
  46.     
  47.   test_for_keypressed :-
  48.     keypressed, 
  49.     write("\nSome key was pressed"), !.
  50.   test_for_keypressed :-
  51.     write("\nNo key is pressed").
  52.  
  53.   write_char(C) :-
  54.     writef("\nWrite char = %", C).
  55.  
  56.   mk_prolog_file :-
  57.     openwrite(textfile, "mytest.txt"),
  58.     writedevice(textfile),
  59.     write("\nThis is a file, and this is line number 1"),
  60.     write("\nThis is a file, and this is line number 2"),
  61.     write("\nThis is a file, and this is line number 3"),
  62.     write("\nThis is a file, and this is line number 4"),
  63.     write("\nThis is a file, and this is line number 5"),
  64.     write("\nThis is a file, and this is line number 6"),
  65.     write("\nThis is a file, and this is line number 7"),
  66.     writedevice(screen),
  67.     closefile(textfile).
  68.  
  69.  
  70. domains
  71.   ilist = integer*
  72.  
  73. predicates
  74.   stack_test(integer, ilist, ilist);
  75.  
  76. clauses
  77.   stack_test(I, In, Out) :-
  78.     I < 10,!,
  79.     I1 = I + 1,
  80.     stack_test(I1, [I1 | In], Out).
  81.   stack_test(_, L, L).
  82.  
  83.  
  84. goal 
  85.   wait("HELLO This is Prolog"),
  86.   write("\nTesting stack"),
  87.   stack_test(0, [], Res),
  88.   write(", I'm still alive, List = ", Res),
  89.   wait("Now go to C"),
  90.   testproc,
  91.   wait("Goodbye from Prolog").
  92.