// QueryAnswer constructor /// <summary> Returns the value of the specified variable or <code>null</code> if the /// variable is not bound. /// /// </summary> /// <param name="name">the name of the variable /// </param> /// <returns> the value of the variable as a {@link se.sics.prologbeans.PBTerm} /// or <code>null</code> if the variable is not bound /// </returns> public override PBTerm getValue(string name) { if (!bound) { if (hasValues) { // [PM] 4.1.3 No longer rely on answer being a PBListCell // copy all the new bindings into Bindings PBTerm list; // [PM] 4.1.3 for type checking only. Barfs if not a proper // list. (FIXME: redundant) answer.length(); for (list = answer; list.ListCell; list = list.getArgument(2)) { PBTerm bindTerm = list.getArgument(1); if (bindTerm.Name.Equals("=")) { bind(bindTerm.getArgument(1).Name, bindTerm.getArgument(2)); } } // assert list.isEmptyList(); } bound = true; } return(base.getValue(name)); }
/// <summary> Returns the error reason or <code>null</code> if an error has not /// occurred or if no error reason is known. /// </summary> /// <returns> the error, or null, if none /// </returns> public virtual string getError() { if (answer.Name.Equals("error")) { return(answer.getArgument(1).ToString()); } return(null); }
/* * private static bool compare(PBString pbstr, String str) * { * PBList pbl = pbstr; * int i; * for (i = 0; i < str.Length && pbl.Length != 0; i++) { * int c = pbl.getArgument(1).intValue(); * if (c != str[i]) { * return false; * } else { * pbl = (PBList)(pbl.getArgument(2)); * } * } * if (i < str.Length || pbl.Length != 0) { * return false; * } * return true; * } */ private static bool listcompare(PBTerm pbl, String str) { int i; for (i = 0; i < str.Length && pbl.length() != 0; i++) { long c = pbl.getArgument(1).intValue(); if (c != str[i]) { return(false); } else { pbl = pbl.getArgument(2); } } if (i < str.Length || pbl.length() != 0) { return(false); } return(true); }
private static bool listcompare(PBTerm t1, PBTerm t2) { int i; if (t1.length() != t2.length()) { return(false); } for (i = 0; t1.length() != 0; i++) { long c1 = t1.getArgument(1).intValue(); long c2 = t2.getArgument(1).intValue(); if (c1 != c2) { return(false); } else { t1 = t1.getArgument(2); t2 = t2.getArgument(2); } } return(true); }
private static bool listcompare(PBTerm t1, PBTerm t2) { int i; if (t1.length() != t2.length()) { return false; } for (i = 0; t1.length() != 0; i++) { long c1 = t1.getArgument(1).intValue(); long c2 = t2.getArgument(1).intValue(); if (c1 != c2) { return false; } else { t1 = t1.getArgument(2); t2 = t2.getArgument(2); } } return true; }
/* private static bool compare(PBString pbstr, String str) { PBList pbl = pbstr; int i; for (i = 0; i < str.Length && pbl.Length != 0; i++) { int c = pbl.getArgument(1).intValue(); if (c != str[i]) { return false; } else { pbl = (PBList)(pbl.getArgument(2)); } } if (i < str.Length || pbl.Length != 0) { return false; } return true; } */ private static bool listcompare(PBTerm pbl, String str) { int i; for (i = 0; i < str.Length && pbl.length() != 0; i++) { long c = pbl.getArgument(1).intValue(); if (c != str[i]) { return false; } else { pbl = pbl.getArgument(2); } } if (i < str.Length || pbl.length() != 0) { return false; } return true; }