Thank you.
I just recall some statement from the old versions documentation that the facts need to be groupped.
But I had the same facts as now with the old 5.2x version and everything then was OK,
I don't understand why VP8 has a problem with these databases.
Michael
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
-
- VIP Member
- Posts: 73
- Joined: 19 Nov 2016 7:58
I modified a little your code as follows, in order to increment the line counter and then just understand where the error is with my database, however this gives me syntax errors.
Can you please help me with my recursive predicates?
showBadTerms(FN, Line) :-
IS = inputStream_file::openFile(FN),
check_Bad_Terms(FN, Line, IS),
IS:close(),
!.
check_Bad_Terms(_FN, _, IS) :-
IS:endOfStream(), !.
check_Bad_Terms(FN, Line, IS) :-
not(IS:endOfStream()),
S = IS:readLine(),
NLine = Line + 1,
%string::lastChar(S,S2,_), % you must remove the trailing '.'
if Term = tryToTerm(backend_dbase, S) then
% NOTE: you can try to convert a string to ANY fact term
% in the database and then assert it
%assert( Term ),
console::write("\nAsserted : ", Term)
else
console::write("\nFailed to assert line '", S, "' line : ", Line)
end if,
check_Bad_Terms(FN, NLine, IS),
!.
Can you please help me with my recursive predicates?
showBadTerms(FN, Line) :-
IS = inputStream_file::openFile(FN),
check_Bad_Terms(FN, Line, IS),
IS:close(),
!.
check_Bad_Terms(_FN, _, IS) :-
IS:endOfStream(), !.
check_Bad_Terms(FN, Line, IS) :-
not(IS:endOfStream()),
S = IS:readLine(),
NLine = Line + 1,
%string::lastChar(S,S2,_), % you must remove the trailing '.'
if Term = tryToTerm(backend_dbase, S) then
% NOTE: you can try to convert a string to ANY fact term
% in the database and then assert it
%assert( Term ),
console::write("\nAsserted : ", Term)
else
console::write("\nFailed to assert line '", S, "' line : ", Line)
end if,
check_Bad_Terms(FN, NLine, IS),
!.
PrologUser
-
- VIP Member
- Posts: 458
- Joined: 5 Nov 2000 0:01
You can use a mutable variable for line counting. See LineNum below.
Remember that VP 5.x database files do NOT have a trailing '.', unlike the VP 7.5 and (I assume) 8.0.
Also, your code will be much easier to read if you use the Code button to format it before posting.
Remember that VP 5.x database files do NOT have a trailing '.', unlike the VP 7.5 and (I assume) 8.0.
Also, your code will be much easier to read if you use the Code button to format it before posting.
Code: Select all
class predicates
showBadTerms : ( string FileName ).
clauses
showBadTerms( FN ):-
LineNum = varm::new(0),
IS = inputStream_file::openFile( FN ),
IS:repeatToEndOfStream(),
S = IS:readLine(),
LineNum:value := LineNum:value + 1,
string::lastChar(S,S2,_), % NOTE: there is NO trailing '.' in VP 5.x saved file
if Term = tryToTerm( testDB, S2 ) then
assert( Term ),
console::write("\nAsserted : ", Term )
else
console::write("\nFailed to assert line #", LineNum:value, " '", S , "'")
end if,
IS:endOfStream(),
IS:close(), !.
showBadTerms( FN ):-
stdio::write("\nAbnormal exit in ", predicate_fullname(), " reading ", FN ).
-
- VIP Member
- Posts: 73
- Joined: 19 Nov 2016 7:58
-
- VIP Member
- Posts: 73
- Joined: 19 Nov 2016 7:58
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
I can consult your file with this program:
Code: Select all
implement main
class facts - db
type_def : (integer, string, integer, string, integer, string, integer, integer, integer).
op_def : (integer, string, string, integer, integer, integer, integer).
hierarchy_part : (integer, string, integer, string, integer, integer, integer).
data_stmt : (string, string, integer, integer, string, ii).
local_object : (lo).
prog_stmt : (string, integer, integer, integer, integer, integer, integer, integer).
special_op : (string, integer, string, integer, integer, integer, string, integer, integer, integer).
special_dt : (string, integer, string, integer, string, string, ii).
state_node : (sn).
source_is_normal_dt : (string, integer, integer).
last_change_op_number : (string, integer, integer).
change_op_number : (string, integer, integer).
joint_stmt : (string, integer, integer, integer, integer, integer).
cessor : (string, integer, integer).
cessor_kind : (string, string, integer, integer, string, string, integer*).
guard_cond : (string, integer, integer, string).
guard_pair : (string, integer, integer, string).
op_guards : (string, integer, integer*, integer*).
predecessors : (string, integer, integer*).
rec_stmt : (string, integer, integer*).
var_guards : (string, integer, integer*, integer*).
domains
ii =
i(integer);
sym(string);
bit_wire(string).
lo = local_object(string, integer, string, string, integer, string, string, integer, ii).
sn = state_node(string, integer, cc).
cc =
dataflow(integer*, integer);
ifthen(integer*, integer*, integer*, integer, integer);
jump(integer*, integer).
clauses
run() :-
file::consult(@"..\ITF_FACT.DBA", db).
end implement main
goal
console::runUtf8(main::run).
Regards Thomas Linder Puls
PDC
PDC
-
- VIP Member
- Posts: 73
- Joined: 19 Nov 2016 7:58
Dear Thomas I am doing exactly the same as you,
and showBadTerms proceeds ok until the middle of local_object(local_object( facts (it asserts them ok)
but then sunddenly it interrupts and issues error: invalid handle.
I also tried the same dba file with fullstops (.) at the end of each line, and I get again the same
error.
I will send you confidentially the class facts portion and the goal portion of my project to look at,
and tell me if I am doing something wrong.
and showBadTerms proceeds ok until the middle of local_object(local_object( facts (it asserts them ok)
but then sunddenly it interrupts and issues error: invalid handle.
I also tried the same dba file with fullstops (.) at the end of each line, and I get again the same
error.
I will send you confidentially the class facts portion and the goal portion of my project to look at,
and tell me if I am doing something wrong.
PrologUser
-
- VIP Member
- Posts: 73
- Joined: 19 Nov 2016 7:58