Unable to use LoadXML() with OpenXMLDialog()

Found an issue in SpiderBasic ? Please report it here !
Quin
Posts: 12
Joined: Wed Nov 08, 2023 4:38 pm

Unable to use LoadXML() with OpenXMLDialog()

Post by Quin »

I'm not sure if this behavior applies to more cases than just this, but you're unable to use OpenXMLDialog() with LoadXML(). It says c.xml is undefined.
Here's the code:

Code: Select all

#Xml = 0
#Dialog = 0

If LoadXML(#Xml, "test.xml") And XMLStatus(#Xml) = #PB_XML_Success

  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "dialog1")
    Debug "Dialog successfully created"
      Else
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
Else
  Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
And here's test.xml:

Code: Select all

<window id='#PB_Any' name='dialog1' text='Dialog example' minwidth='300' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>
       <vbox>
             <option name='option1' text='Enter your credit card:' group='1'/>
             <string name='string' width='50' height='30'/>
             <option name='option2' text='Use paypal account' group='1'/>
             <option name='option3' text='Use wiretransfert' group='1'/>
             <hbox>
               <button name='ok' text='Continue' height='35'/>
               <button name='cancel' text='Cancel'/>
             </hbox>
       </vbox>
         </window>
         
SB 2.51, x86, Windows, using Firefox to render the app.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Unable to use LoadXML() with OpenXMLDialog()

Post by Peter »

SpiderBasic Help wrote: LoadXML()

[...]

Return value

Nonzero if the xml object has been created. The xml data is still not loaded, the callbacks binded to #PB_Event_Loading and #PB_Event_LoadingError will be called once the loading is done. If #PB_Any was used for the #XML parameter then the generated number is returned on success.

Code: Select all

EnableExplicit

#Xml = 0
#Dialog = 0

Procedure Loading(Type, Filename.s)
  
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "dialog1")
    Debug "Dialog successfully created"
  Else
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
  
EndProcedure

Procedure LoadingError(Type, Filename.s)
  Debug Filename + ": loading error"
EndProcedure


; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading,      @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())

LoadXML(#XML, "test.xml")
Quin
Posts: 12
Joined: Wed Nov 08, 2023 4:38 pm

Re: Unable to use LoadXML() with OpenXMLDialog()

Post by Quin »

Nope, that causes the same result here :(

Code: Select all

Uncaught TypeError: c.xml is undefined
spider_MainXMLNode
http://127.0.0.1:9080/spiderbasic.js?t=1707083223:296

spider_OpenXMLDialog
http://127.0.0.1:9080/spiderbasic.js?t=1707083223:355

f_loading
http://127.0.0.1:9080/spiderbasic.js?t=1707083223:363

SendLoading
http://127.0.0.1:9080/spiderbasic.js?t=1707083223:98

success
http://127.0.0.1:9080/spiderbasic.js?t=1707083223:293

jQuery
4

[Learn More]
spiderbasic.js:296:351
Peter wrote: Sat Feb 03, 2024 12:25 am
SpiderBasic Help wrote: LoadXML()

[...]

Return value

Nonzero if the xml object has been created. The xml data is still not loaded, the callbacks binded to #PB_Event_Loading and #PB_Event_LoadingError will be called once the loading is done. If #PB_Any was used for the #XML parameter then the generated number is returned on success.

Code: Select all

EnableExplicit

#Xml = 0
#Dialog = 0

Procedure Loading(Type, Filename.s)
  
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "dialog1")
    Debug "Dialog successfully created"
  Else
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
  
EndProcedure

Procedure LoadingError(Type, Filename.s)
  Debug Filename + ": loading error"
EndProcedure


; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading,      @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())

LoadXML(#XML, "test.xml")
Post Reply