Found an issue in SpiderBasic ? Please report it here !
tj1010
 
Posts: 186
Joined: Wed May 27, 2015 1:36 pm

A couple new Dialog bugs

by tj1010 Sat Mar 31, 2018 5:03 pm

I had some time and finished a project over the past few days, but found some new bugs in Dialog lib just while testing under x86 browsers like latest chrome.

Here is my code, and I'll point out how to reproduce the bugs below it
Code: Select all
Procedure updatecost()
  ;shows how much is made based on cash on hand minus owed and other metrics
  Protected i.l
  Protected sixty.f
  Protected made.f
  Protected profit.f
  Protected gas.f
  Protected cc.f
  ;total made
  For i = 0 To CountGadgetItems(DialogGadget(0,"flist"))
    If CountString(GetGadgetItemText(DialogGadget(0,"flist"),i),"-")=0 And CountString(GetGadgetItemText(DialogGadget(0,"flist"),i),"c")=0
      made=made+ValF(GetGadgetItemText(DialogGadget(0,"flist"),i))
    EndIf
  Next
  ;owed
  sixty=(60.0 * made) / 100.0
  ;profit before gas
  profit=ValF(GetGadgetText(DialogGadget(0,"onhand")))-sixty
  ;profit after gas
  gas=profit
  For i = 0 To CountGadgetItems(DialogGadget(0,"flist"))
    If CountString(GetGadgetItemText(DialogGadget(0,"flist"),i),"-")=1
      gas=gas-ValF(RemoveString(GetGadgetItemText(DialogGadget(0,"flist"),i),"-"))
    EndIf
  Next
  ;total minus CC
  For i = 0 To CountGadgetItems(DialogGadget(0,"flist"))
    If CountString(GetGadgetItemText(DialogGadget(0,"flist"),i),"c")>0
      cc=cc+ValF(RemoveString(GetGadgetItemText(DialogGadget(0,"flist"),i),"c"))
    EndIf
  Next
  ClearGadgetItems(DialogGadget(0,"output"))
  AddGadgetItem(DialogGadget(0,"output"),-1,"Profit:"+StrF(profit,2))
  AddGadgetItem(DialogGadget(0,"output"),-1,"Owed:"+StrF(sixty,2))
  AddGadgetItem(DialogGadget(0,"output"),-1,"After Gas:"+StrF(gas,2))
  AddGadgetItem(DialogGadget(0,"output"),-1,"Total:"+StrF(made,2))
  AddGadgetItem(DialogGadget(0,"output"),-1,"Total Minus CC:"+StrF((made-cc),2))
EndProcedure

Procedure OrientationChange()
EndProcedure

Procedure wdata(Status, Filename$, File, SizeRead)
  Select Status
    Case #PB_Status_Saved
    Case #PB_Status_Error
    Case #PB_Status_Loaded
      SetGadgetText(DialogGadget(0,"onhand"),Trim(ReadString(0)))
      ClearGadgetItems(DialogGadget(0,"flist"))
      While Eof(0)=0
        line$=Trim(ReadString(0))
        If CountString(line$,".")>0 : AddGadgetItem(DialogGadget(0,"flist"),-1,line$) : EndIf
        line$=""
      Wend
      CloseFile(0)
      updatecost()
  EndSelect
EndProcedure

Procedure openfilez()
  Protected line.s
  If NextSelectedFile()
    ReadFile(0, SelectedFileID(), @wdata(), #PB_LocalFile)
  EndIf
EndProcedure

Runtime Procedure reset()
  SetGadgetText(DialogGadget(0,"onhand"),"Cash On Hand")
  SetGadgetText(DialogGadget(0,"newfigure"),"Item To Add")
  ClearGadgetItems(DialogGadget(0,"output"))
  ClearGadgetItems(DialogGadget(0,"flist"))
EndProcedure

Runtime Procedure add()
  If ValF(Trim(GetGadgetText(DialogGadget(0,"newfigure"))))<>0.0
    AddGadgetItem(DialogGadget(0,"flist"),-1,Trim(GetGadgetText(DialogGadget(0,"newfigure"))))
    SetGadgetText(DialogGadget(0,"newfigure"),"Item To Add")
    updatecost()
  EndIf
EndProcedure

Runtime Procedure remove()
  If GetGadgetState(DialogGadget(0,"flist"))>-1 : RemoveGadgetItem(DialogGadget(0,"flist"),GetGadgetState(DialogGadget(0,"flist"))) : EndIf
  updatecost()
EndProcedure

Runtime Procedure filehandler()
  If CountGadgetItems(DialogGadget(0,"flist"))>0
    ;export
    If CreateFile(0,"export.txt",@wdata())
      WriteStringN(0,Trim(GetGadgetText(DialogGadget(0,"onhand"))))
      For i = 0 To CountGadgetItems(DialogGadget(0,"flist"))
        WriteStringN(0,Trim(GetGadgetItemText(DialogGadget(0,"flist"),i)))
      Next
      ExportFile(0,"text/plain")
      CloseFile(0)
    EndIf
  Else
    ;import
    OpenFileRequester("",@openfilez())
  EndIf
EndProcedure

ExamineDesktops()
XML$ = "<window id='#PB_Any' name='somewindow' text='' minwidth='"+DesktopWidth(0)+"' minheight='"+DesktopHeight(0)+"' flags='#PB_Window_ScreenCentered|#PB_Window_BorderLess'>" +
       "    <gridbox colexpand='yes' rowexpand='item:16'>" +
       "      <listview name='output' colspan='2' rowspan='10' />" +
       "      <button name='reset' text='Reset' colspan='2' onevent='reset()' />" +
       "      <string name='onhand' colspan='2' text='Cash On Hand' />" +
       "      <string name='newfigure' colspan='2' text='Item To Add' />" +
       "      <button name='add' text='Add' colspan='2' onevent='add()' />" +
       "      <button name='xport' text='Import/Export' colspan='2' onevent='filehandler()' />" +
       "      <listview name='flist' colspan='2' onevent='remove()' />" +
       "    </gridbox>" +
       "  </window>"

If ParseXML(0, XML$) And XMLStatus(0) = #PB_XML_Success
  If CreateDialog(0) And OpenXMLDialog(0,0,"somewindow")
    SetGadgetColor(DialogGadget(0,"output"),#PB_Gadget_BackColor,RGB(0,0,0))
    SetGadgetColor(DialogGadget(0,"output"),#PB_Gadget_FrontColor,RGB(255,245,0))
  EndIf
EndIf

BindEvent(#PB_Event_SizeDesktop, @OrientationChange())


  1. In XML$ declaration rowspan on the first listview try 15 and then 16(huge difference)
  2. rowexpand "item:7" expands the first stringfield and not the last listview
  3. If rowspan on the "Reset" button is too low a value it goes behind other elements
  4. Trying anything on any Dialog gadget except onevent="" will bug out the entire app; for example: onleftclick and onleftdoubleclick no matter the case
  5. AddGadgetItem doesn't work on editor gadget like it does in PB it just silently fails(nothing even in F12 console)
  6. Not using Runtime on Procedure call from dialogs onevent doesn't throw a compiler or runtime error(not really a issue just putting it here for the record)
  7. item:1000 on rowexpand expands an invisible element
  8. NON-DIALOG-ISSUE SB doesn't use carriage return on WriteStringN recognized by programs like Windows notepad.exe

That's all except some minor geometry precision issues
Fred
Site Admin
 
Posts: 1298
Joined: Mon Feb 24, 2014 10:51 am

Re: A couple new Dialog bugs

by Fred Thu Apr 30, 2020 9:40 am

You specified 'rowspan = 10' for the first listview, so it takes 10 items. Items are row, not gadgets. That's why specified item:7 grows the first listview() instead of the last.

I tried several 'onchange()' on stringgadget() and it does work, please provide a code showing than other than onevent() doesn't work.

To see the error when creating a dialog, you need to use DialogError() if OpenXMLDialog() call fail.
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 3 guests