public static void htmlExecuteRetrieveQuery(int nvalues, Cons variables, Cons query, Cons options, Module mod, org.powerloom.PrintableStringWriter stream) {
    { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

      try {
        Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
        { QueryIterator queryiterator = null;
          Cons solutions = Stella.NIL;

          { Module mdl000 = mod;
            Context cxt000 = mdl000;

            if (mdl000 == null) {
              mdl000 = ((Module)(Stella.$MODULE$.get()));
              cxt000 = ((Context)(Stella.$CONTEXT$.get()));
            }
            { Object old$Module$000 = Stella.$MODULE$.get();
              Object old$Context$000 = Stella.$CONTEXT$.get();

              try {
                Native.setSpecial(Stella.$MODULE$, mdl000);
                Native.setSpecial(Stella.$CONTEXT$, cxt000);
                synchronized (Logic.$POWERLOOM_LOCK$) {
                  queryiterator = Logic.callRetrieve(Cons.cons(((nvalues > 0) ? ((Stella_Object)(IntegerWrapper.wrapInteger(nvalues))) : ((Stella_Object)(OntosaurusUtil.SYM_LOGIC_ALL))), Cons.cons(variables, Cons.cons(query, options.concatenate(Stella.NIL, Stella.NIL)))));
                }

              } finally {
                Stella.$CONTEXT$.set(old$Context$000);
                Stella.$MODULE$.set(old$Module$000);
              }
            }
          }
          solutions = queryiterator.consifyCurrentSolutions();
          {
            stream.print("<HTML>");
            {
              stream.print("<HEAD>");
              stream.println("<BASE TARGET='content'>");
              {
                stream.print("<TITLE>");
                stream.print("Answer Page");
                stream.println("</TITLE>");
              }
              stream.println("</HEAD>");
            }
            { String tag011 = OntosaurusUtil.makeHtmlBodyTag(OntosaurusUtil.$ANSWER_BACKGROUND_COLOR$);

              stream.print("<" + tag011 + ">");
              if (queryiterator.timeoutP) {
                stream.println("The query timed out.<BR>");
              }
              if (solutions == Stella.NIL) {
                {
                  stream.print("<FONT COLOR='#CC3366'>");
                  {
                    stream.print("<I>");
                    stream.print("No Solutions");
                    stream.print("</I>");
                  }
                  stream.println("</FONT>");
                }
              }
              else {
                { Cons soln = null;
                  Cons iter000 = solutions;
                  int answercounter = Stella.NULL_INTEGER;
                  int iter001 = 1;

                  for (;!(iter000 == Stella.NIL); iter000 = iter000.rest, iter001 = iter001 + 1) {
                    soln = ((Cons)(iter000.value));
                    answercounter = iter001;
                    {
                      stream.print("<DL>");
                      {
                        stream.print("<DT>");
                        {
                          stream.print("<FONT COLOR='#999999'>");
                          stream.println("Solution " + answercounter + ":");
                          OntosaurusUtil.writeExplanationIcon(queryiterator, soln, stream);
                          stream.print("</FONT>");
                        }
                        stream.println("</DT>");
                      }
                      { Stella_Object binding = null;
                        Cons iter002 = soln;
                        Stella_Object var = null;
                        Cons iter003 = variables;

                        for (;(!(iter002 == Stella.NIL)) &&
                                  (!(iter003 == Stella.NIL)); iter002 = iter002.rest, iter003 = iter003.rest) {
                          binding = iter002.value;
                          var = iter003.value;
                          {
                            stream.print("<DD>");
                            stream.print(var + " = ");
                            if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(binding), OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
                              { LogicObject binding000 = ((LogicObject)(binding));

                                OntosaurusUtil.htmlWriteHref(stream, "show", "concept", binding000);
                              }
                            }
                            else {
                              stream.print(binding);
                            }
                            stream.println("</DD>");
                          }
                        }
                      }
                      stream.println("</DL>");
                    }
                  }
                }
              }
              stream.println("</" + Native.string_subsequence(tag011, 0, Native.string_position(tag011, ' ', 0)) + ">");
            }
            stream.println("</HTML>");
          }
        }

      } finally {
        Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
      }
    }
  }