Well, hmm, yes, this is what I actually use, and it works pretty well. I
didn't want to use it in the first place (the dark side of the force is
always tempting ;), but I must admit that it was a mistake.

Thanks a lot for the quick answer.

Emmanuel Lecharny, IKTEK
06 08 33 32 61, www.iktek.com <http://www.iktek.com>


-----Message d'origine-----
De : friedman_hill ernest j [mailto:[EMAIL PROTECTED]]
Envoye : mercredi 20 juin 2001 20:18
A : Emmanuel Lecharny
Cc : 'Jess Mailing List'
Objet : Re: JESS: " in strings


Value.stringValue() will convert almost any kind of Value to a String,
including floats, so why not use it?

  public String stringValue(Context c) throws JessException
  {
    switch (m_type)
      {
      case RU.ATOM:
      case RU.STRING:
      case RU.VARIABLE:
      case RU.MULTIVARIABLE:
      case RU.SLOT:
      case RU.MULTISLOT:
        return (String) m_objectval;
      case RU.INTEGER:
        return String.valueOf(m_intval);
      case RU.FLOAT:
        return String.valueOf(m_floatval);
      case RU.EXTERNAL_ADDRESS:
        return m_objectval.toString();
      default:
        throw typeError("stringValue", "Not a string");
      }
  }

The string produced by Value.toString() is meant to be suitable for
writing out to a file and later reparsed; it's employed during
save-facts, for example.


I think Emmanuel Lecharny wrote:
> Hi,
>
> just a question about strings and " : I want to store a string and fetch
it
> from a Java program. This string contains some ", as it is a subset of
HTML
> tags (ie : <a href="link"> ...)
>
> I bound a variable to this string : (bind ?a "<a href \"link\">) and
stored
> it : (store a-tag ?a)
>
> If I printout it : (printout t ?a t) , I get : <a href="link">, which is
> what I'm waiting for. But in my java program, when I fetch this a-tag, I
get
> <a href=\"link\">.
>
> I must admit that I fetch somtehing that IS a string but that could be
> something else, so I tried just to toString the value I got. This is the
> point, as if I use the stringValue method, I just get what I expected, but
> as I don't really know (in this part of my program) if it will be a String
> or a float, I prefer to send the result as a String to the caller.
>
> In the Value class, the toString transform a String by adding a \ before
> each " :
>
>       case RU.STRING:
>         return "\"" + escape((String) m_objectval) + "\"";
>
> Is this a normal behavior? does it have an impact if the String is not
> escaped?
>


---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550


---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to