Karel XML - Boolean read/write

  • Hello All,


    I have question regarding BOOLEAN variable and read/write from an XML file. I have a xml tag which has an attribute whose value is "1" . At Karel side, I have defined a structure with a boolean variable.


    When I read using the XML_SETVAR builtin function in a Karel program into the structure, it is automatically converted to "True". Then after writing this value to another XML file, when i try to read it again, it (meaning "True") is not recognised as a Boolean but as a string.


    Does anyone know how to retain the boolean status (either retaining "1" or reading "True" as a Boolean)?


    Thanks and Regards

    Anand

  • Place your Ad here!
  • I create a file and write it line by line with xml tags.

    For example like

    Code
    WRITE file('<TAGNAME ATTRIBUTENAME="',STRUCT.BOOLVAR,'">',CR)
    WRITE File('</TAGNAME>',CR)

    Inside the STRUCT structure, I have defined a boolean variable which initially gets "1" from my source XML file (somehow converts itself to "True" - I checked this in Roboguide). After seeing the written XML file, I find STRUCT.BOOLVAR = " True" (An empty character at the start. Again dont know why).

  • Yes, that could be one way. I created a small function just to convert this "True" "False" as "1" or "0" before writing. I just dont understand why FANUC doesnt read "True" or "False" directly as Boolean. Thanks for the input hermann.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners