, save consult, . , - , , '. ᒺ , , , , .
, . , .
readterm :
readterm (DomainName, TermRecord),
DomainName , TermRecord , ᒺ, .
, , , . dbasedom, . ³ . , - :
database
rson (name, age, sex)
address (firm, street, house, grup)
dbasedom:
domains
dbasedom = rson (name, age, sex); address (firm, street, house, grup),
, - - .
. 6_2, address() adres.dba.
6_3, l(), 6_2. , , , .
/* 6_3 */
/* , , adres.dba */
domains
firm, street, group = symbol
house = integer
file = file_bd
database
address (firm, street, house, group)
predicates
place (firm, street, house, group)
my_read (dbasedom)
my_append (dbasedom)
next_rec (file)
clauses
my_read (Record) :- openread (file_bd, adres. dba), readdevice (file_bd), next_rec (file_bd), readterm (dbasedom, Record).
my_append (Record) :- openappend (file_bd, adres. dba), writedevice (file_bd), write (Record), nl, closefile (file_bd).
next_rec (_).
next_rec (File) :- not (eof (File)), next_rec (File).
place (F, S, N, G) :- bound (F), my_read (R), R=address (F, S, N, G),!.
place (F, S, N, G) :- free (F), my_read (R), R=address (F, S, N, G).
place (F, S, N, G) :- bound (F), free (S), free (N), readdevice (key board), write ( , F), nl, write ( : ), readln (S), write ( : ), readreal (N), write (: ), readln (G), closefile (file_bd), my_append (address (F, S, N, G)).
|
|
, , . file_bd. .
6_3 . my_read my_append. next_rec repeat , .
place() , my_read (R), R .
address (F, S, N, G). , my_read (R), R . , , .
, F, S, N, G , , , , . , , place().
my read() file_db adres.dba .
file_db . , read, , , , , .
, . , next_rec () , (eof ()) .
, Record , . , Record , .
my pend() file_db adres.dba .
file_db . , write, , , , .
( ) , Record.
ϳ .
, . . , .
place() , , readdevice (keyboard) . ϳ . , .
|
|
, . ³ .