Пролог

dengul

New member
11.05.2013
1
0
#1
Доброго времени суток!

пишу простую БД на turbo prolog 2. складской учёт

суть в одной ошибке из-за которой я собственно и не могу закончить программу, я её переписывал уже 4 раза (разные алгоритмы), и опять выскакивает та же ошибка "703 This flow pattern doesn't exist. (Look in the message window)"

текст программы

Код:
domains
name,unit,cena,total,date,type=string 
file=f

database
dsklad (name,unit,cena,total,date,type) 

predicates
menu					 
reaction(char)									  
findtype(char)
find_name(name,unit,cena,total,date,type)
find_date(name,unit,cena,total,date,type)
find(char)						 
start 	

clauses
find_name(name,unit,cena,total,date,type):-
dsklad (name,unit,cena,total,date,type),!.
find_name(_,"Error! Record not found...",_,_,_,_).

find_date(name,unit,cena,total,date,type):-
dsklad (name,unit,cena,total,date,type),!.
find_date("Error! Record not found...",_,_,_,_,_).

findtype(N):- 
clearwindow,
write("1 - Poisk po naimenovaniy tovara"),nl,
write("2 - Poisk po date "),nl,
write("3 - Vernutsja na glavnoe menu"),nl,
readchar(N).

find('1'):-		
clearwindow,
Write("Enter the name of the goods: "),nl,
readln(name),
find_name(name,unit,cena,total,date,type),
Write(name,unit,cena,total,date,type),
readchar(_),menu.

find('2'):-	 
clearwindow,
write("Enter the desired date: "),nl,
readln(date),
find_date(name,unit,cena,total,date,type),
Write(name,unit,cena,total,date,type),
readchar(_),menu.

find('3'):-	 menu.

menu:- 
clearwindow,
write("1- Add record "),nl,
write("2- Delete record "),nl,
write("3- Find the entry "),nl, 
write("4- Change the record "),nl,
/*	write("5- Stocktaking "),nl, */
write("0- Exit"), nl, 
readchar(N), reaction(N).

reaction('1'):-  
clearwindow,
write("Enter the name of the goods: "),nl,
ругается тут----------	readln(name),
write("Unit of measurement: "),nl,
readln(unit),
write("The price for one unit of: "),nl,
readln(cena),
write("Quantity of goods: "),nl,
readln(total),
write("Date: "),nl,
readln(date),
write("parish or loss?: "),nl,
readln(type),
assert(dsklad(name,unit,cena,total,date,type)), 
write("Accepted record"),menu.

reaction('2'):-
clearwindow,
write("Specify the name of the deleted product: "),nl,
readln(name),
retract(dsklad(name,_,_,_,_,_)),
menu.

reaction('3'):-
clearwindow,
findtype(N),find(N),menu.



reaction('4'):-
clearwindow,
write(" |_Enter the new information_| "),nl,
write("Enter the name of the goods: "), nl,
readln(name),
write("Unit of measurement: "),nl,
readln(unit),
write("The price for one unit of: "),nl,
readln(cena),
write("Quantity of goods: "),nl,
readln(total),
write("Date: "),nl,
readln(date),
write("Parish or Loss?: "),nl,
readln(type),
retract(dsklad(name,_,_,_,_,_)),
assert(dsklad(name,unit,cena,total,date,type)), 
write("Accepted record"),menu.

/*	reaction('5'):- */	

reaction('0'):- 
save("sklad.ddb"),
retractall(_).

reaction(_) :-
menu.

start:-
existfile("sklad.ddb"),!, 
consult("sklad.ddb "), 
menu. 
start:-
openwrite(f,"sklad.ddb"),	 
closefile(f),
menu. 

goal

makewindow(1, 10, 3, "_DATA BASE SKLAD_ ", 3, 10, 19, 60, 1, -1,
"\218\191\192\217\196\179"), start.