Weird problem after ELSE
Posted: Thu May 18, 2017 4:28 pm
Hi, I am completely new to spiderbasic and I have a limited experience in web programming, so please be patient
I am going to paste a piece of code and trying to make you understand the problem:
At the end of the code I call, depending on a menu, the newDLG() method. It works and shows the dialog. On it, if I push Cancel, the freedialog(0) call releases an closes the dialog (calling the RunTime cancelNewDlg()). If I push OK (calling the RunTime doNewDlg()), I check four stringgadgets to avoid emptyness. This check is done in an IF statement and shows an alert, but if all four have strings, the ELSE simply hangs the application, even I cannot show Debug statements
Any advise will be appreciated
THX

I am going to paste a piece of code and trying to make you understand the problem:
Code: Select all
!$("head").append("<link rel='stylesheet' type='text/css' href='Data/js/messi.css' />");
!$.getScript("Data/js/messi.js", loadok);
!function loadok()
!{
Debug "OK"
!}
Structure Player
name.s
finalres.l
EndStructure
Global Dim players.Player(4)
Global currentHand = 0
Global txtP1, txtP2, txtP3, txtP4
Procedure CloseWindowEvent()
CloseWindow(EventWindow())
EndProcedure
Procedure GadgetEvents()
Select EventGadget()
EndSelect
EndProcedure
Procedure Alert(title.s,message.s)
!new Messi(v_message, {title: v_title, width: '200px', titleClass: 'anim error', modal: true , buttons: [{id: 0, label: 'Close', val: 'X'}]});
EndProcedure
Runtime Procedure doNewDlg()
If GetGadgetText(DialogGadget(0, "player1")) = "" Or
GetGadgetText(DialogGadget(0, "player2")) = "" Or
GetGadgetText(DialogGadget(0, "player3")) = "" Or
GetGadgetText(DialogGadget(0, "player4")) = ""
Alert("New","Names cannot be empty")
Else
; Set names and initialize scores
players(0)\name = UCase(GetGadgetText(DialogGadget(0, "player1")))
players(0)\finalres = 0
players(1)\name = UCase(GetGadgetText(DialogGadget(0, "player2")))
players(1)\finalres = 0
players(2)\name = UCase(GetGadgetText(DialogGadget(0, "player3")))
players(2)\finalres = 0
players(3)\name = UCase(GetGadgetText(DialogGadget(0, "player4")))
players(3)\finalres = 0
currentHand = 1
FreeDialog(0)
EndIf
EndProcedure
Runtime Procedure cancelNewDlg()
FreeDialog(0)
EndProcedure
Procedure newDlg()
#Dialog = 0
#Xml = 0
XML$ = "<window id='#PB_Any' name='new' text='New game' minwidth='auto' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SizeGadget'>" +
" <vbox expand='no'>" +
" <text text='Player #1' />" +
" <string name='player1' text='' width='200' />" +
" <text text='Player #2' />" +
" <string name='player2' text='' width='200' />" +
" <text text='Player #3' />" +
" <string name='player2' text='' width='200' />" +
" <text text='Player #4' />" +
" <string name='player3' text='' width='200' />" +
" <empty /> " +
" <empty /> " +
" <hbox expand='equal'>" +
" <button text='Ok' onevent='doNewDlg()' height='30' />" +
" <button text='Cancel' onevent='cancelNewDlg()' height='30' />" +
" </hbox>" +
" </vbox>" +
" </window>"
If ParseXML(#Xml, XML$) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "new")
Debug "Dialog created"
Else
Debug "Dialog error: " + DialogError(#Dialog)
EndIf
Else
Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
EndProcedure
Procedure MenuEvents()
Select EventMenu()
Case 0 ; New
newDlg()
Case 1 ; Load
Case 2 ; Save
Case 3 ; Undo
Case 4 ; Draw
Case 4 ; Show
EndSelect
EndProcedure
Any advise will be appreciated
THX