For retrieval of Terms from a Chain, can the "HasDomain" Domain parameter be set with a runtime variable (and reset during backtracking)?
Alternatively, I thought you could create a Domain with all of the Domains you would ever need (see below) and use that with HasDomain. My example below works for the first Domain (customers), but fails during the first backtrack, after successfully working with the first Domain (customers).
e.g.
domains
myData = c(customers);p(part_name, iD, customer_name).
Am I doomed to creating a Clause for each Chain solely for the purpose of setting the HasDomain parameter?
The dream is to scan through DB Chains dumping out the Terms as it backtracks. Below is the error I get during backtracking and my code snippet. Note that the Chain Name and Chain Domain are the same (e.g. Chain 'customers" has one Domain also named "customers"
********************
DB Name = Common.dba
NoOfTerms=8 MemSize=5968 DbaSize=6422 Free=2304217088
Chain name = customers
Term: customer("S1 Joe Fraser","S1 LA Ca")
Term: customer("S2 John Smith","S2 RSM Ca")
Term: customer("Joe Blow","Portland OR")
Term: customer("Sally Doe","Seattle Wa")
Chain name = parts
Exception in module: OneClass.exe
c:\program files (x86)\visual prolog 7.5\pfc\collection\algebraic\redblacktree\redblacktree.pro(252) : error r304: Invalid binary for the do
main 'data::customers' in ::toTerm( $[53,00,31,00,20,00,57,00,72,00 ... ] )
C:\Users\Administrator\Documents\Visual Prolog Projects\OneClass\Exe>pause
Press any key to continue . . .
Code: Select all
getChainInfo(MyDB):-
MyDB:db_chains(MyChain),
stdIO::write("\nChain name = ",MyChain),
% hasDomain(MyChain,SomeTerm),
%Above is what I wish would work because MyChain (by design) always equals the Chain's Term Domain.
hasDomain(customers,SomeTerm), %Always works for the customers Chain
MyDB:chain_terms(MyChain,SomeTerm, _), %Get the Term
stdIO::write("\nTerm: ",SomeTerm), %Print it
fail. %Backtracking to read the "parts" and "shipments" Chains and their Terms
/* notes */
% hasDomain(parts,SomeTerm), %What I need for the first backtrack
% hasDomain(shipments,SomeTerm), %What I need for the second backtrack
% hasDomain(myData,SomeTerm), %Trying a Domain with the 3 Domains above (customers, parts and Shipments). Always works for the customers Chain, but fails on backtracking (parts Domain)
/* notes */
constants
partChain = "parts".
customerChain = "customers".
shipmentChain ="shipments".
domains
%myData = c(customers);p(parts);s(shipments). %Fails on backtrack
%myData = p(parts);s(shipments);c(customers). %Fails on backtrack
myData = c(customers);p(part_name, iD, customer_name);s(chaindb::ref,chaindb::ref). %Fails on backtrack
customers = customer(customer_name,address).
parts = part(part_name, iD, customer_name).
shipments = shipment(chaindb::ref,chaindb::ref).
Thanks in advance.
Larry