Как исправить ошибку: This flow pattern does not exist (Prolog)?

Ругается на key_insert(autoDB, AutoBT, Number, R). Кажется мне, что AutoBT свободная переменная, но почему?
DOMAINS
    db_selector = autoDB
    carBrands, 
    num,
    ownerName = string
    price = real
    saleAuto = row(carBrands, num, price, ownerName)
PREDICATES
    item(char, bt_selector) 
    menu(bt_selector)
    show(ref, bt_selector) 
    print(saleAuto)
CLAUSES
    menu(AutoBT) :-
        makewindow(1,14,3,"AutoSales",0,0,25,80),
        clearwindow,
        write("1. Add new record \n"),
        write("2. Remove record \n"),
        write("3. Replace record \n"),
        write("4. Show records \n"),
        readchar(C),
        item(C,AutoBT).
    item('1',AutoBT) :-
        clearwindow,
        write("Brand of car > "),
        readln(Brand),
        write("Car number > "),
        readln(Number),
        write("Price of car > "),
        readreal(Price),
        write("Owner name > "),
        readln(Name),
        chain_insertz(autoDB,someChain,saleAuto,row(Brand,Number,Price,Name),R),
        key_insert(autoDB, AutoBT, Number, R),
        readchar(_),
        menu(_).
    item('2',AutoBT) :-
        clearwindow,
        write("Input Car Number > "),
        readln(Number),
        chain_terms(autoDB,someChain,saleAuto,row(_,Number,_,_),R),
        key_delete(autoDB, AutoBT, Number, R),
        term_delete(autoDB,someChain,R),
        write("Remove successful!"),
        readchar(_),
        menu(_).
    item('3',_) :-
        clearwindow,
        write("Input Car Namber > "),
        readln(Number),
        chain_terms(autoDB,someChain,saleAuto,row(_,Number,_,_),R),
        ref_term(autoDB, saleAuto, R, Term),
        write("Record is found:", Term, "Enter replace information. \n"),
        write("Brand of car > "),
        readln(Brand),
        write("Price of car > "),
        readreal(Price),
        write("Owner name > "),
        readln(Name),
        term_replace(autoDB, saleAuto, R, row(Brand,Number,Price,Name)),
        write("Replace successful"),
        readchar(_),
        menu(_).
    item('4',AutoBT) :-
        clearwindow,
        write("|    Brand     |Number|   Price    |        Name          |\n"),
        key_first(autoDB, AutoBT, R),
        show(R,_).
    show(R,_) :-
        ref_term(autoDB, saleAuto, R, Term),
        print(Term),
        fail.
    show(_,AutoBT) :-
        key_next(autoDB,AutoBT,NextR),
        !,
        show(NextR,_).
    show(_,_) :-
        readchar(_),
        menu(_).    
    print(row(Brand,Number,Price,Name)) :-
        writef("| %-12 | %-4 | %10.2f | %-20 |\n",Brand,Number,Price,Name).
GOAL
    db_create(autoDB, "auto.txt", in_file),
    db_close(autoDB),
    db_open(autoDB, "auto.txt", in_file),
    bt_create(autoDB, "autoBtree", AutoBT, 4, 5),
    %bt_close(autoDB, AutoBT),
    %bt_open(autoDB, "autoBtree", AutoBT),
    menu(AutoBT).
  • Вопрос задан
  • 3761 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы