[Solved] Screen not updating

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

[Solved] Screen not updating

Post by AndyGable »

Hi all,

I am sending messages to my user via a label called SysMessage but I am only getting the first one to show

when the form loads I get on screen

Code: Select all

labSystemMessage.Caption = "Starting End of Day" & gb.crlf & "Please wait..."
labSystemMessage.Refresh
and this is correct but then i am sending the message

Code: Select all

labSystemMessage.Caption = "Creating End of day Report - Cash In Drawer"
labSystemMessage.Refresh
frmClosePoS.Refresh
But the above message is not being shown (it acts like it is stuck on the first one)

If someone could tell me what I am doing wrong I would appreciate it as I am sending a lot of messages to my user on this form but none of them are being displayed.

This is the code behind the form

' Gambas class file

Public Sub Form_Open()


    labSystemMessage.Caption = "Starting End of Day" & gb.crlf & "Please wait..."
    labSystemMessage.Refresh
    
    With Me.Timer1
        .Delay = 1000
        .Enabled = True
        .Start
    End With
End


Public Sub Timer1_Timer()

    Sleep 1
    Me.Timer1.Stop
    StartCloseFunction

End


Private Sub StartCloseFunction()

    Select Case global.EndOfDayAction
        Case "Print"
            PrintReportOut
            'SaveFigures
            EndOfDay
            
        Case "SaveOnly"
            'SaveReport
            'SaveFigures
            EndOfDay
            
        Case "SavePrint", "PrintSave"
            PrintReportOut
            'SaveReport
            'SaveFigures
            EndOfDay
    End Select

End

Private Sub EndOfDay()
    
    labSystemMessage.Caption = "Resetting PoS Figures to Zero"
    labSystemMessage.Refresh
    ZeroTenderValuesSave
    Sleep 1
    
    frmbackground.Workspace1.CloseAll
    MenuDisplay.ClearMenu
    frmbackground.Workspace1.Add(frmSignedOff, 0)

End

Private Sub PrintReportOut()
    
    If global.CaptureCashDrawer = "Yes" Then
        labSystemMessage.Caption = "Creating End of day Report - Cash In Drawer"
        labSystemMessage.Refresh
        frmClosePoS.Refresh
        StartPrint
    End If

    labSystemMessage.Caption = "Creating End of day Report - Lottery Summary"
    labSystemMessage.Refresh
    frmClosePoS.Refresh
    LotterySummary

    labSystemMessage.Caption = "Creating End of day Report - Payout Summary"
    labSystemMessage.Refresh
    frmClosePoS.Refresh
    PrintPayoutSummary

    If global.ModuleCardProcessing = "PaymentSense" Then
        labSystemMessage.Caption = "Running End of Day on Payment Terminal"
        labSystemMessage.Refresh        
        frmClosePoS.Refresh
        'EndOfDayPaymentSense
    End If

    labSystemMessage.Caption = "Creating PoS Summary Report"
    labSystemMessage.Refresh    
    frmClosePoS.Refresh
    PoSSummaryReport


    If global.SafeDropActive = "Yes" Then
        labSystemMessage.Caption = "Creating Safe Drop Summary Report"
        labSystemMessage.Refresh    
        frmClosePoS.Refresh
        SafeDropSummary
    End If

    labSystemMessage.Caption = "Reloading PoS Figures"
    labSystemMessage.Refresh    
    frmClosePoS.Refresh
    BootUp.LoadTenderValues
    
    Select Case global.EndOfDayAction
        Case "Print"
            labSystemMessage.Caption = "Printing End Of Day Report"
            labSystemMessage.Refresh
            frmClosePoS.Refresh
            PrinterFunctions.PrintEndOfSlip(0)
            SaveFigures

        Case "SaveOnly"
            labSystemMessage.Caption = "Saving End of Day Report"
            labSystemMessage.Refresh
            frmClosePoS.Refresh
            SaveFigures
            'SaveReport
            
            labSystemMessage.Caption = "Saving End of Day Figure"
            labSystemMessage.Refresh
            frmClosePoS.Refresh
            SaveFigures
        
        Case "SavePrint", "PrintSave"
            labSystemMessage.Caption = "Printing End Of Day Report"
            labSystemMessage.Refresh
            frmClosePoS.Refresh
            PrinterFunctions.PrintEndOfSlip(0)

            labSystemMessage.Caption = "Saving End of Day Report"
            labSystemMessage.Refresh
            frmClosePoS.Refresh
            'SaveReport
            
            labSystemMessage.Caption = "Saving End of Day Figure"
            labSystemMessage.Refresh
            frmClosePoS.Refresh
            SaveFigures

    End Select

End


Private Sub PrintPayoutSummary()
    
    
    
End


Private Sub LotterySummary()
    Dim Totals As Integer = 0
    
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "Lottery Summary" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    Global.PrinterData &= Global.CentreAlignText & global.NormalFont & "** THIS REPORT IS ONLY FOR THIS TERMINAL **" "~"

    PrintTenderValue("  NATIONAL LOTTERY", Format((Global.NationLotteryPayout / 100), "£0.00"))
    PrintTenderValue("     EURO MILLIONS", Format((Global.EuroMillionsPayout / 100), "£0.00"))
    PrintTenderValue("      SET FOR LIFE", Format((Global.SetForLifePayout / 100), "£0.00"))
    PrintTenderValue("       THUNDERBALL", Format((Global.ThunderballPayout / 100), "£0.00"))
    PrintTenderValue("   LOTTO HOT PICKS", Format((Global.LottoHotPicksPayout / 100), "£0.00"))
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    PrintTenderValue("      SCRACH CARDS", Format((Global.ScrachCardPayout / 100), "£0.00"))
    
    totals = Global.NationLotteryPayout + Global.EuroMillionsPayout + Global.SetForLifePayout + Global.ThunderballPayout + Global.LottoHotPicksPayout + Global.ScrachCardPayout
    
    PrintTotal("Lottery Total", Format((totals / 100), "£0.00"))
    
End


'Private Sub EndOfDayPaymentSense()
    
  ' This makes the Payment Sense Terminal Run the end of day and banking and returns the report to this screen
   'download the data and create a report here
    
'End

Private Sub SaveFigures()
  Dim LocalData As String = Null
  
    LocalData &= Format(Now, "yyyy/mm/dd") & "|"
    LocalData &= Format(Now, "hh:nn") & "|"
    LocalData &= Format(Global.PoSNumber, "000") & "|"
    LocalData &= Format(Global.CashierNumber, "0000") & "|"
    LocalData &= global.CashierNamePrint & "|"
    
    
    LocalData &= Global.Normal_Cash & "|"
    LocalData &= Global.Normal_Cheque & "|"
    LocalData &= Global.Normal_Card & "|"
    LocalData &= Global.Normal_Coupon & "|"
    LocalData &= Global.Normal_GiftVoucher & "|"
    LocalData &= Global.Normal_GiftCard & "|"
    LocalData &= "0|"
'    Global.Normal_OnAccount
    
    LocalData &= Global.refund_Cash & "|"
    LocalData &= Global.refund_Cheque & "|"
    LocalData &= Global.refund_Card & "|"
    LocalData &= Global.refund_Coupon & "|"
    LocalData &= Global.refund_GiftVoucher & "|"
    LocalData &= Global.refund_GiftCard & "|"
    LocalData &= "0|"
    'Global.refund_OnAccount

    LocalData &= global.CustomerCount & "|"
    LocalData &= Global.NoSaleCount & "|"
    
    LocalData &= Global.TotalSaleVoids & "|"
    LocalData &= Global.NumberOfTotalSaleVoids & "|"

    LocalData &= Global.TotalSafeDrop & "|"
    LocalData &= global.SafeDropCount
    
    SystemFunctions.WriteFileData(Application.path, "EODFigures.eodf", LocalData)
    
End

Private Sub PoSSummaryReport()
    Dim TotalSale As Integer = 0
    Dim TotalRefund As Integer = 0
    Dim TotalFloat As Integer = 0
    Dim Totals As Integer = 0
    
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "PoS Summary" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "Sales" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"

    Global.PrinterData &= Global.LeftAlignText & global.BoldNormalFont & "TENDER TYPE                         TOTAL" & "~"
    
    PrintTenderValue("              CASH", Format((Global.Normal_Cash / 100), "£0.00"))
    PrintTenderValue("              CARD", Format((Global.Normal_Card / 100), "£0.00"))
    PrintTenderValue("           COUPONS", Format((Global.Normal_Coupon / 100), "£0.00"))
    PrintTenderValue("        GIFT CARDS", Format((Global.Normal_GiftCard / 100), "£0.00"))
    PrintTenderValue("     GIFT VOUCHERS", Format((Global.Normal_GiftVoucher / 100), "£0.00"))
    PrintTenderValue("            CHEQUE", Format((Global.Normal_Cheque / 100), "£0.00"))
    PrintTenderValue("        ON ACCOUNT", Format((Global.Normal_OnAccount / 100), "£0.00"))
    
    TotalSale = Global.Normal_Cash + Global.Normal_Card + Global.Normal_Coupon + Global.Normal_GiftCard + Global.Normal_GiftVoucher + Global.Normal_Cheque + Global.Normal_OnAccount

    PrintTotal("Sales Total", Format((TotalSale / 100), "£0.00"))
    
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "Refunds" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    Global.PrinterData &= Global.LeftAlignText & global.BoldNormalFont & "TENDER TYPE                         TOTAL" & "~"

    PrintTenderValue("              CASH", Format((Global.refund_Cash / 100), "£0.00"))
    PrintTenderValue("              CARD", Format((Global.refund_Card / 100), "£0.00"))
    PrintTenderValue("           COUPONS", Format((Global.refund_Coupon / 100), "£0.00"))
    PrintTenderValue("        GIFT CARDS", Format((Global.refund_GiftCard / 100), "£0.00"))
    PrintTenderValue("     GIFT VOUCHERS", Format((Global.refund_GiftVoucher / 100), "£0.00"))
    PrintTenderValue("            CHEQUE", Format((Global.refund_Cheque / 100), "£0.00"))
    PrintTenderValue("        ON ACCOUNT", Format((Global.refund_OnAccount / 100), "£0.00"))

    TotalRefund = Global.Refund_Cash + Global.Refund_Card + Global.Refund_Coupon + Global.Refund_GiftCard + Global.Refund_GiftVoucher + Global.Refund_Cheque + Global.Refund_OnAccount

    PrintTotal("Refunds Total", Format((TotalRefund / 100), "£0.00"))
    
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "Float Summary" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    PrintTenderValue("          FLOAT IN", Format((Global.FloatIn / 100), "£0.00"))
    PrintTenderValue("         FLOAT OUT", Format((Global.FloatIn / 100), "£0.00"))
    
    TotalFloat = global.Floatin - global.FloatOut
    
    PrintTotal("Differance ", Format((TotalFloat / 100), "£0.00"))
     
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "PoS Summary" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    
    PrintTenderValue("    CUSTOMER COUNT", Global.CustomerCount & " ")
    PrintTenderValue("     NO SALE COUNT", Global.NoSaleCount & " ")
    PrintTenderValue(" TOTAL VOIDS COUNT", Global.NumberOfTotalSaleVoids & " ")
    PrintTenderValue(" TOTAL VOIDS VALUE", Format((Global.TotalSaleVoids / 100), "£0.00"))
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
    PrintTenderValue("   SAFE DROP VALUE", Format((Global.TotalSafeDrop / 100), "£0.00"))
    
   
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "~"
   
    totals = TotalSale + Global.TotalSafeDrop - TotalRefund
      
    Global.PrinterData &= Global.LeftAlignText & global.BoldDoubleHeightFont & "Terminal Total" & "~"
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    Global.PrinterData &= Global.RightAlignText & global.BoldDoubleWidthHeightFont & Format((totals / 100), "£0.00") & "~"

End


Private Sub SafeDropSummary()
    '2022/09/10,20:42,1105,Andrew,100.00

    Dim LineData As String = Null

    If Exist(SafeDropDataFile) = True Then
        Global.hFile1 = Open SafeDropDataFile For Input
            While Not Eof(Global.hFile1) 
                Line Input #Global.hFile1, Linedata 
                
                global.LineMessages = Split(Linedata, ",")
                
                Global.LineMessages[0] 'Date
                Global.LineMessages[1] 'Time
                Global.LineMessages[2] 'Cashier
                Global.LineMessages[3] 'Cashier Name
                Global.LineMessages[4] ' Value Dropped
                
                'Add to the print out so it can be porinted with the rest of the report
                



            Wend
        Global.hFile1.Close
        'Kill SafeDropDataFile
    Else
        
        ' Print a No Safe Drop done
    End If
    
    
    
    

End



Private Sub StartPrint()
Dim TempPrint As String = global.PrinterData

    Global.PrinterData = Null
    
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    Global.PrinterData &= Global.CentreAlignText & global.BoldDoubleWidthHeightFont & "END OF DAY" & "~"
    
    If global.PrintDayOnReport = "Yes" Then
        Global.PrinterData &= Global.CentreAlignText & global.BoldNormalFont & global.PrintDayOnReportFunction(Now) & "~"
    End If
    
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"

    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & "Cash in drawer" & "~"
    Global.PrinterData &= TempPrint

End




Private Sub ZeroTenderValuesSave()

    Kill Global.PoSTenderFile

    Dim TenderLocalFile As Settings

    ' This sets the system to load from the tenders.conf file
    TenderLocalFile = New Settings(Global.PoSTenderFile)

                               TenderLocalFile["Tenders/Cash"] = "0"
                               TenderLocalFile["Tenders/Card"] = "0"
                             TenderLocalFile["Tenders/Coupon"] = "0"
                           TenderLocalFile["Tenders/GiftCard"] = "0"
                        TenderLocalFile["Tenders/GiftVoucher"] = "0"
                             TenderLocalFile["Tenders/Cheque"] = "0"
                          TenderLocalFile["Tenders/OnAccount"] = "0"

    'Refund Values
                               TenderLocalFile["Refunds/Cash"] = "0"
                               TenderLocalFile["Refunds/Card"] = "0"
                             TenderLocalFile["Refunds/Coupon"] = "0"
                           TenderLocalFile["Refunds/GiftCard"] = "0"
                        TenderLocalFile["Refunds/GiftVoucher"] = "0"
                             TenderLocalFile["Refunds/Cheque"] = "0"
                          TenderLocalFile["Refunds/OnAccount"] = "0"
                    
    'Float Settings
                              TenderLocalFile["Float/FloatIn"] = "0"
                             TenderLocalFile["Float/FloatOut"] = "0"
    
    'Safe Drop Total
                            TenderLocalFile["Safe Drop/Count"] = "0"
                     TenderLocalFile["Safe Drop/TotalDropped"] = "0"
    
    'Lottery Payouts
        TenderLocalFile["Lottery Payouts/NationLotteryPayout"] = "0"
         TenderLocalFile["Lottery Payouts/EuroMillionsPayout"] = "0"
           TenderLocalFile["Lottery Payouts/SetForLifePayout"] = "0"
          TenderLocalFile["Lottery Payouts/ThunderballPayout"] = "0"
        TenderLocalFile["Lottery Payouts/LottoHotPicksPayout"] = "0"
           TenderLocalFile["Lottery Payouts/ScrachCardPayout"] = "0"

    'PoS Settings

                 TenderLocalFile["PoS Settings/CustomerCount"] = "0"
                   TenderLocalFile["PoS Settings/NoSaleCount"] = "0"
        TenderLocalFile["PoS Settings/NumberOfTotalSaleVoids"] = "0"
                TenderLocalFile["PoS Settings/TotalSaleVoids"] = "0"

End

Private Sub PrintTenderValue(TenderName As String, TenderValue As String)
    Dim SPaceBetweenQtyTotal As Integer = 42 - (String.Len(TenderName) + Len(TenderValue))
   
    Global.PrinterData &= Global.LeftAlignText & global.BoldNormalFont & TenderName & Space(SPaceBetweenQtyTotal) & TenderValue & "~"
End

Private Sub PrintTotal(PrintName As String, TotalValue As String)
    Global.PrinterData &= Global.LeftAlignText & global.NormalFont & String(Global.PrinterWidth, "-") & "~"
    Global.PrinterData &= Global.RightAlignText & global.BoldDoubleHeightFont & PrintName & " " & TotalValue & " " & "~"
End
Last edited by AndyGable on Wednesday 14th December 2022 10:22pm, edited 1 time in total.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Screen not updating

Post by BruceSteers »

Try using Wait to let the event loop run

You may find it better to use "Wait 1" where you use "Sleep 1" or whatever the value..

Sleep completely halts your program but Wait will allow the event loop to catch up while it pauses.

I have fixed many an object refresh problem by adding a "Wait" or "Wait 0.1" or "Wait Next" instruction after updating it.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Screen not updating

Post by BruceSteers »

something like this...
    If global.CaptureCashDrawer = "Yes" Then
        labSystemMessage.Caption = "Creating End of day Report - Cash In Drawer"
        labSystemMessage.Refresh
        frmClosePoS.Refresh
        Wait 0.1
        StartPrint
    End If


then all the objects can catch up and refresh in the "Wait" before StartPrint begins

You will find some functions hold up the event loop so using Wait you can let it catch up

Hope that makes sense
If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Screen not updating

Post by AndyGable »

@BruceSteers

Thanks for that I'll try it when I get to the computer

Also would it be better to keep the timer or would wait 3 wait 3 seconds and then start the process?
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Screen not updating

Post by BruceSteers »

AndyGable wrote: Saturday 10th December 2022 10:27am @BruceSteers

Thanks for that I'll try it when I get to the computer

Also would it be better to keep the timer or would wait 3 wait 3 seconds and then start the process?
Defo timer.
If you want to use methods automatically at program start then a timer is best as the Form_Open needs to complete to show your window.
instructions run in Form_Open happen "before" the window opens so if your GUI shows info for the process it will not be seen.

using a Timer allows the form to open and finish initializing before you begin a process..
If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Screen not updating

Post by AndyGable »

Thanks @BruceSteers that worked perfectly
Post Reply