[Solved] Possible bug in dialog: text='<'

Just starting out? Need help? Post your questions and find answers here.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

[Solved] Possible bug in dialog: text='<'

Post by davido »

The following test code shows that > is allowed whereas < is not allowed in the text attribute in dialog objects.
Surely this is a bug.

I've tested the code in Windows 7-64 and Mac Mavericks.

In the code below:
Line 26 is ok but
Line 27 throws the error: XML error: not well-formed (invalid token) (Line: 1)

Code: Select all

  ; As we embedded xml directly in the source, the encoding of special characters will vary if we are in unicode mode or not. 
  ; So ensure to use the correct one. This is not needed if the XML is read from an external file or directly included
  ; with IncludeBinary.
  ;
  CompilerIf #PB_Compiler_Unicode
    #XmlEncoding = #PB_UTF8
  CompilerElse 
    #XmlEncoding = #PB_Ascii
  CompilerEndIf
  
  Runtime Procedure OpenWindowDialog()
  ExamineDesktops()
  Protected H = DesktopHeight(0)
  
  
  #Dialog = 0
  #Xml = 0
  Debug H
  
  XML$ = "<dialogs>" +
         "<window id='0' name='First Window' text='First Window' width='600' height='700' " +
         " flags= '#PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
         "  <vbox>"+
         "   <hbox maxheight='100'>"+
         "     <empty height='50' />"+
         "     <button text='>' height='40'/>" +
         "     <button text='|<' height='40'/>" +
         "   </hbox>"+
         "   <empty width='500' height='550'/>"+
         "  </vbox> "+
         "</window>" +
         "<window id='1' name='Second Window' text='Second Window' width='200' height='200'" +
         " flags='#PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
         "" +
         "</window>" +
         "<window id='2' name='Third Window' text='Third Window' width='200' height='200'" +
         " flags='#PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
         "" +
         "</window>" +
         "</dialogs>"

  
  If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
    
    If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "First Window") And
       OpenXMLDialog(#Dialog, #Xml, "Second Window") And (OpenXMLDialog(#Dialog, #Xml, "Third Window"))
      Debug WindowHeight(0)
      Debug WindowWidth(0)
      ResizeWindow(0,200,#PB_Ignore,#PB_Ignore,#PB_Ignore)
      ResizeWindow(1,200 + WindowWidth(0),#PB_Ignore,#PB_Ignore,#PB_Ignore)
      Repeat
        Event = WaitWindowEvent()
      Until Event = #PB_Event_CloseWindow 
      
    Else  
      Debug "Dialog error: " + DialogError(#Dialog)
    EndIf
  Else
    Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
  EndIf
    
  EndProcedure
  
OpenWindowDialog()
Last edited by davido on Sat Apr 05, 2014 9:00 pm, edited 1 time in total.
DE AA EB
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Possible but in dialog: text='<'

Post by freak »

You need to use < instead of < otherwise it is not valid XML.
quidquid Latine dictum sit altum videtur
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Possible but in dialog: text='<'

Post by davido »

@freak

Thanks very much for your rapid reply. :D
DE AA EB
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Possible but in dialog: text='<'

Post by rsts »

freak wrote:You need to use < instead of < otherwise it is not valid XML.
Fred didn't let you go on holiday? ;)
Post Reply