<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div><div><div>% The builtin comparison operation on strings is also implementation</div><div>% dependent. The current implementation performs string comparison using</div><div>%</div><div>% - C's strcmp() function, when compiling to C;</div></div><div><br></div><div>Guided by the text, "The builtin comparison operation on strings "... I assumed that >, <, >= etc would work fork string types but my code:</div><div><br></div><div><div><font face="Andale Mono"> 615 op_greater_than(!Mode, !Stk) :-</font></div><div><font face="Andale Mono"> 616 ( if [ V1, V2 | Rest ] = !.Stk then</font></div><div><font face="Andale Mono"> 617 !:Stk = Rest,</font></div><div><font face="Andale Mono"> 618</font></div><div><font face="Andale Mono"> 619 ( if V1 = int(N1), V2 = int(N2) then</font></div><div><font face="Andale Mono"> 620 trace [io(!IO)] (</font></div><div><font face="Andale Mono"> 621 io.format("> %s %s\n", [s(string(V1)),s(string(V2))],!IO)</font></div><div><font face="Andale Mono"> 622 ),</font></div><div><font face="Andale Mono"> 623 ( if N1 > N2</font></div><div><font face="Andale Mono"> 624 then push_true(!Mode, !Stk)</font></div><div><font face="Andale Mono"> 625 else push_false(!Mode, !Stk)</font></div><div><font face="Andale Mono"> 626 )</font></div><div><font face="Andale Mono"> 627</font></div><div><font face="Andale Mono"> 628 else if V1 = str(S1), V2 = str(S2) then</font></div><div><font face="Andale Mono"> 629 trace [io(!IO)] (</font></div><div><font face="Andale Mono"> 630 io.format("> %s %s\n", [s(string(V1)),s(string(V2))],!IO)</font></div><div><font face="Andale Mono"> 631 ),</font></div><div><font face="Andale Mono"> 632 ( if S1 > S2</font></div><div><font face="Andale Mono"> 633 then push_true(!Mode, !Stk)</font></div><div><font face="Andale Mono"> 634 else push_false(!Mode, !Stk)</font></div><div><font face="Andale Mono"> 635 )</font></div><div><font face="Andale Mono"> 636 else</font></div><div><font face="Andale Mono"> 637 seterr("> requires two objects of the same type.", !Mode)</font></div></div><div><br></div><div>gets these errors:</div><div><br></div><div><div><font face="Andale Mono">dstack.m:632: In clause for predicate `op_greater_than'/4:</font></div><div><font face="Andale Mono">dstack.m:632: in call to predicate `int.>'/2:</font></div><div><font face="Andale Mono">dstack.m:632: in argument 1:</font></div><div><font face="Andale Mono">dstack.m:632: variable `S1' has type</font></div><div><font face="Andale Mono">dstack.m:632: string,</font></div><div><font face="Andale Mono">dstack.m:632: expected type was</font></div><div><font face="Andale Mono">dstack.m:632: int;</font></div><div><font face="Andale Mono">dstack.m:632: in argument 2:</font></div><div><font face="Andale Mono">dstack.m:632: variable `S2' has type</font></div><div><font face="Andale Mono">dstack.m:632: string,</font></div><div><font face="Andale Mono">dstack.m:632: expected type was</font></div><div><font face="Andale Mono">dstack.m:632: int.</font></div></div><div><br></div><div><br></div><div>So what is the 'way' to do string comparisons? I find it odd in all the code I've written, I have never needed to do this before!</div><div><br></div><div>Thanks,</div><div>Sean.</div><div><br></div></body></html>