1
여기 내 프롤로그 데이터베이스 코드입니다.질의 결과를 프롤로그에 파일로 작성
:-
dynamic myTable/2.
init :-
removeAll,
asserta(myTable('avalue', 'another value')),
asserta(myTable('avalue1', 'another value 1')),
asserta(myTable('avalue2', 'another value 2')),
asserta(myTable('avalue3', 'another value 3')),
asserta(myTable('avalue4', 'another value 4')).
read(Col1, Col2) :-
myTable(Col1, Col2).
saveQueries(FileName) :-
tell(FileName).
stopSavingQueries :-
told.
파일로 프롤로그 출력 저장을 시작하려고합니다. 파일에 저장해야하는 동적 데이터베이스에 대한 쿼리를 만든 다음 쿼리 저장을 중지합니다.
?- init.
true.
?- saveQueries('queries.txt').
true.
?- read(Col1, Col2).
...
?- stopSavingQueries.
true.
이 코드 파일을 실행하면 queries.txt
이 생성됩니다. read(Col1, Col2).
을 실행하면 콘솔에 출력이 표시되고 queries.txt
파일은 비어 있습니다.