Page 1 of 1

4.61 - wrong error message (NO BUG, sorry)

Posted: Sun Aug 19, 2012 10:54 am
by rudd68
If I use "Read" in a procedure, the program doesn't work. This is bad.

If I compile this program with the F5 key, then a wrong error message occurs.

Code: Select all

; Wrong error message

EnableExplicit

DataSection
  
  Cards:                ; each row is a card, -1 ist the end of the cards data  
  
  Data.w 825, 0, 0, 225, 0, 160, 20, 0, 200
  Data.w 775, 0, 0, 250, 0, 175, 0, 50, 200
  Data.w 700, 0, 0, 237, 0, 176, 0, 0, 0
  Data.w 633, 0, 0, 0, 0, 0, 0, 188, 193
  Data.w 965, 0, 0, 200, 35, 200, 0, 200, 130
  Data.w 651, 0, 110, 250, 0, 168, 0, 1, 192
  Data.w 600, 0, 0, 250, 0, 160, 40, 0, 150
  Data.w 580, 0, 0, 250, 90, 230, 70, 200, 180
  Data.w 600, 0, 0, 247, 0, 200, 0, 210, 200
  
  Data.w -1
  
EndDataSection


#Window1 = 0
#Titel = "Wrong error message"
#h = 400
#w = 600


Global.w Number_of_cards
Define.i Window_Flags, Event 

Procedure Try(Result.i, MessageText.s)
  
  If Result = #False
    MessageRequester("Error", MessageText, #PB_MessageRequester_Ok)
    End
  EndIf
  
EndProcedure

Procedure Count_Cards()
  
  ; each data row is one card
  
  Protected.i i
  Protected.w value
    
  Number_of_cards = 0
      
  Restore Cards
  Read.w value
  
  While value <> -1
    
    Number_of_cards + 1
    
    For i = 1 To 8   ; rest of data row
      Read.w value
    Next i
    
    Read.w value     ; new data row
    
  Wend
  
ProcedureReturn 
  


Window_Flags = #PB_Window_ScreenCentered | #PB_Window_TitleBar | #PB_Window_SystemMenu
Window_Flags | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget

Try(OpenWindow(#Window1, 0, 0, #w, #h, #Titel, Window_Flags), "Can not open window.")

Count_Cards()

Repeat  

  Event = WaitWindowEvent()
  
  Select Event
      
    Case #PB_Event_CloseWindow
      
      End
      
  EndSelect
      
ForEver
      


Re: 4.61 - wrong error message

Posted: Sun Aug 19, 2012 11:03 am
by luis
rudd68 wrote:If I use "Read" in a procedure, the program doesn't work. This is bad.
Something is bad, all right. You forgot

Code: Select all

EndProcedure
after ProcedureReturn.

Re: 4.61 - wrong error message (NO BUG)

Posted: Sun Aug 19, 2012 11:16 am
by rudd68
Sorry, that's my fault. It works just fine. :D