home *** CD-ROM | disk | FTP | other *** search
Prolog Source | 1990-03-26 | 2.1 KB | 92 lines |
-
- domains
- file = textfile
-
- global predicates
- write_storage_left language c as "_write_storage_left"
- write_double(real) - (i) language c as "_write_double"
- write_string(string) - (i) language c as "_write_string"
- test_for_keypressed language c as "_test_for_keypressed"
- write_char(char) - (i) language c as "_write_char"
- mk_prolog_file language c as "_mk_prolog_file"
- wait(string)-(i) language c as "_wait"
-
- % This is defined in the C code
- testproc language c as "_testproc"
-
- PREDICATES
- repwr(INTEGER)
-
-
- clauses
- repwr(0):-!.
- repwr(N):-
- write('-'),
- N1=N-1,
- repwr(N1).
-
- wait(STR):-
- nl,
- str_len(STR,LEN),
- REP=(80-LEN) div 2 -2,
- repwr(REP),
- write(' ',STR,' '),
- repwr(REP),
- readchar(_).
-
- write_storage_left :-
- write("\nStorage dump from prolog code:"),
- storage.
-
- write_double(D) :-
- writef("\nWrite double = %", D).
-
- write_string(S) :-
- write(S).
-
- test_for_keypressed :-
- keypressed,
- write("\nSome key was pressed"), !.
- test_for_keypressed :-
- write("\nNo key is pressed").
-
- write_char(C) :-
- writef("\nWrite char = %", C).
-
- mk_prolog_file :-
- openwrite(textfile, "mytest.txt"),
- writedevice(textfile),
- write("\nThis is a file, and this is line number 1"),
- write("\nThis is a file, and this is line number 2"),
- write("\nThis is a file, and this is line number 3"),
- write("\nThis is a file, and this is line number 4"),
- write("\nThis is a file, and this is line number 5"),
- write("\nThis is a file, and this is line number 6"),
- write("\nThis is a file, and this is line number 7"),
- writedevice(screen),
- closefile(textfile).
-
-
- domains
- ilist = integer*
-
- predicates
- stack_test(integer, ilist, ilist);
-
- clauses
- stack_test(I, In, Out) :-
- I < 10,!,
- I1 = I + 1,
- stack_test(I1, [I1 | In], Out).
- stack_test(_, L, L).
-
-
- goal
- wait("HELLO This is Prolog"),
- write("\nTesting stack"),
- stack_test(0, [], Res),
- write(", I'm still alive, List = ", Res),
- wait("Now go to C"),
- testproc,
- wait("Goodbye from Prolog").
-