Page 1 of 1

The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 5:40 pm
by ClueLess
Hi All

I designed this program as parte of a bigger aplication but it gives an erron on the repeat loop

Code: Select all

;
; This code is automatically generated by the Form Designer.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures need to be put in another source file.
;

Enumeration FormWindow
  #ArtigosWin
EndEnumeration

Enumeration FormGadget
  #Txt_Codigo_Item
  #Txt_Descricao_Item
  #Txt_Custo_Item
  #Txt_Margem_Item
  #Txt_Desconto_Item
  #Opt_Unidade_Item
  #Opt_IVA_Item
  #But_Guardar_Artigo
  #But_Cancelar_Artigo
  #But_Limpar_Artigo
  #Lbl_Codigo_Item
  #Lbl_Descricao_Item
  #Lbl_Unidade_Item
  #Lbl_Custo_Item
  #Lbl_Margem_Item
  #Lbl_IVA_Item
  #Lbl_Desconto_Item
  #Lbl_IVA_Item_Copy1
EndEnumeration

Procedure OpenArtigos(x = 0, y = 0, width = 647, height = 213)
  OpenWindow(#ArtigosWin, x, y, width, height, "", #PB_Window_SystemMenu)
  StringGadget(#Txt_Codigo_Item, 27, 40, 100, 20, "")
  StringGadget(#Txt_Descricao_Item, 147, 40, 353, 20, "")
  StringGadget(#Txt_Custo_Item, 100, 100, 20, 0, "")
  StringGadget(#Txt_Margem_Item, 147, 100, 100, 20, "")
  StringGadget(#Txt_Desconto_Item, 274, 100, 100, 20, "")
  ListViewGadget(#Opt_Unidade_Item, 527, 40, 100, 20)
  AddGadgetItem(#Opt_Unidade_Item, -1, "Unidade")
  AddGadgetItem(#Opt_Unidade_Item, -1, "Metro")
  AddGadgetItem(#Opt_Unidade_Item, -1, "Hora")
  ListViewGadget(#Opt_IVA_Item, 527, 100, 100, 20)
  AddGadgetItem(#Opt_IVA_Item, -1, "14%")
  AddGadgetItem(#Opt_IVA_Item, -1, "Isento")
  ButtonGadget(#But_Guardar_Artigo, 527, 167, 100, 20, "Guardar")
  ButtonGadget(#But_Cancelar_Artigo, 400, 167, 100, 20, "Cancelar")
  ButtonGadget(#But_Limpar_Artigo, 273, 167, 100, 20, "Limpar Form")
  TextGadget(#Lbl_Codigo_Item, 27, 20, 100, 17, "Codigo")
  TextGadget(#Lbl_Descricao_Item, 147, 20, 100, 17, "Descrição")
  TextGadget(#Lbl_Unidade_Item, 527, 20, 100, 17, "Unidade")
  TextGadget(#Lbl_Custo_Item, 27, 80, 100, 17, "Preço de Custo")
  TextGadget(#Lbl_Margem_Item, 147, 80, 100, 17, "Margem")
  TextGadget(#Lbl_IVA_Item, 401, 80, 100, 17, "Taxa de IVA")
  TextGadget(#Lbl_Desconto_Item, 274, 80, 100, 17, "Deconto %")
  TextGadget(#Lbl_IVA_Item_Copy1, 527, 80, 100, 17, "Taxa de IVA")
EndProcedure

Procedure Artigos_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
  
  ProcedureReturn #True
EndProcedure

Repeat
  WaitWindowEvent()
ForEver

I have another similar application witch works fine. Can someone help me with this?

Thanks

Re: The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 6:12 pm
by TI-994A
ClueLess wrote: Tue Sep 17, 2024 5:40 pm...it gives an erron on the repeat loop

It works once a window is opened - simply call OpenArtigos():

Code: Select all

;
; This code is automatically generated by the Form Designer.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures need to be put in another source file.
;

Enumeration FormWindow
  #ArtigosWin
EndEnumeration

Enumeration FormGadget
  #Txt_Codigo_Item
  #Txt_Descricao_Item
  #Txt_Custo_Item
  #Txt_Margem_Item
  #Txt_Desconto_Item
  #Opt_Unidade_Item
  #Opt_IVA_Item
  #But_Guardar_Artigo
  #But_Cancelar_Artigo
  #But_Limpar_Artigo
  #Lbl_Codigo_Item
  #Lbl_Descricao_Item
  #Lbl_Unidade_Item
  #Lbl_Custo_Item
  #Lbl_Margem_Item
  #Lbl_IVA_Item
  #Lbl_Desconto_Item
  #Lbl_IVA_Item_Copy1
EndEnumeration

Procedure OpenArtigos(x = 0, y = 0, width = 647, height = 213)
  OpenWindow(#ArtigosWin, x, y, width, height, "", #PB_Window_SystemMenu)
  StringGadget(#Txt_Codigo_Item, 27, 40, 100, 20, "")
  StringGadget(#Txt_Descricao_Item, 147, 40, 353, 20, "")
  StringGadget(#Txt_Custo_Item, 100, 100, 20, 0, "")
  StringGadget(#Txt_Margem_Item, 147, 100, 100, 20, "")
  StringGadget(#Txt_Desconto_Item, 274, 100, 100, 20, "")
  ListViewGadget(#Opt_Unidade_Item, 527, 40, 100, 20)
  AddGadgetItem(#Opt_Unidade_Item, -1, "Unidade")
  AddGadgetItem(#Opt_Unidade_Item, -1, "Metro")
  AddGadgetItem(#Opt_Unidade_Item, -1, "Hora")
  ListViewGadget(#Opt_IVA_Item, 527, 100, 100, 20)
  AddGadgetItem(#Opt_IVA_Item, -1, "14%")
  AddGadgetItem(#Opt_IVA_Item, -1, "Isento")
  ButtonGadget(#But_Guardar_Artigo, 527, 167, 100, 20, "Guardar")
  ButtonGadget(#But_Cancelar_Artigo, 400, 167, 100, 20, "Cancelar")
  ButtonGadget(#But_Limpar_Artigo, 273, 167, 100, 20, "Limpar Form")
  TextGadget(#Lbl_Codigo_Item, 27, 20, 100, 17, "Codigo")
  TextGadget(#Lbl_Descricao_Item, 147, 20, 100, 17, "Descrição")
  TextGadget(#Lbl_Unidade_Item, 527, 20, 100, 17, "Unidade")
  TextGadget(#Lbl_Custo_Item, 27, 80, 100, 17, "Preço de Custo")
  TextGadget(#Lbl_Margem_Item, 147, 80, 100, 17, "Margem")
  TextGadget(#Lbl_IVA_Item, 401, 80, 100, 17, "Taxa de IVA")
  TextGadget(#Lbl_Desconto_Item, 274, 80, 100, 17, "Deconto %")
  TextGadget(#Lbl_IVA_Item_Copy1, 527, 80, 100, 17, "Taxa de IVA")
EndProcedure

Procedure Artigos_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
  
  ProcedureReturn #True
EndProcedure

OpenArtigos()

Repeat
  WaitWindowEvent()
ForEver

Re: The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 6:14 pm
by mk-soft
Do Not Edit The Form.pbf File. Always overwrite from FormDesigner

Create a main.pb with this code. Check your file name if *.pbf

Code: Select all

XIncludeFile "Form.pbf"

OpenArtigosWin()

Repeat
  event = WaitWindowEvent()
  
  Select EventWindow()
    Case #ArtigosWin
      If ArtigosWin_Events(event) = #False
        Break
      EndIf
      
  EndSelect
ForEver

Re: The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 6:42 pm
by ClueLess
Thank You All

It now started working without making any change

Thank You

Re: The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 6:54 pm
by ClueLess
Hi

I was wrong. Was testing the working one.

Replaced the repeat loop with: Repeat Until #PB_Event_CloseWindow and now get the error Garbage at the end of the line

What the hell is going on?

Re: The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 6:59 pm
by TI-994A
ClueLess wrote: Tue Sep 17, 2024 6:54 pmRepeat Until #PB_Event_CloseWindow

The correct condition should be:

Code: Select all

Repeat
  event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow

Re: The window does not open (was: Can't find the error)

Posted: Tue Sep 17, 2024 7:39 pm
by ClueLess
Solved

Removed the Procedure command at the beguining. Display the Window on the code flow

Re: The window does not open (was: Can't find the error)

Posted: Wed Sep 18, 2024 12:01 am
by boddhi
Hello ClueLess,
ClueLess wrote: Solved
Maybe you can modify your initial post's title to indicate that it's solved.
This is part of good forum practice :wink: