Page 1 of 1

OnError

Posted: Wed Jul 02, 2003 6:30 pm
by dbellis
i have some code here that exes a file when the run button is clicke but i wanted to add debugin support i checked the help and the OnError pb files(i cant read german) can u tell me wot im missing from this.


Code: Select all

OnErrorGoto(ErrorInfo)

#Window_0 = 0
#Button_Run = 0
#Button_About = 1
#Button_Exit = 2

 If OpenWindow(#Window_0, 277, 316, 341, 220,  #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered , "VCD Viewer")
    If CreateGadgetList(WindowID())
      ButtonGadget(#Button_Run, 10, 10, 320, 60, "Run Vcd")
      ButtonGadget(#Button_Exit, 10, 150, 320, 60, "Exit")     
      OnErrorGoto(ErrorInfo)			
    EndIf
  EndIf

Repeat
EventID=WaitWindowEvent()
	Select EventID
	 Case #PB_Event_Gadget
		If  EventGadgetID()=#Button_Run
		  RunProgram("PowerDVD", "", "C:\Program Files\CyberLink\PowerDVD\", 0) 
			OnErrorGoto(ErrorInfo)
		EndIf
		If EventGadgetID()=#Button_Exit
		  Quit=1
			OnErrorGoto(ErrorInfo)
		EndIf
	EndSelect
Until EventID = #PB_EventCloseWindow Or Quit=1 

ErrorInfo:
 GetErrorCounter()
 GetErrorAdress()
 GetErrorDescription()
 
 numerrors=GetErrorCounter()
 adress=GetErrorAdress()
 description$=GetErrorDescription()
 
 MessageRequester("Error:","Error: "+description$+" At Adress: "+adress,0)
 
 OpenFile(0, "C:\Debug.txt") 
  WriteString("Debug Info")
  WriteLong(numerrors)
  WriteLong(adress)
  WriteString(description$)
 CloseFile(0)
End

thx i advance
dbellis

Posted: Wed Jul 02, 2003 7:45 pm
by Rings
replace
OnErrorGoto(ErrorInfo)

with

OnErrorGoto(?ErrorInfo)

:)

Posted: Wed Jul 02, 2003 7:49 pm
by Rings
and those lines:

Code: Select all

GetErrorCounter() 
GetErrorAdress() 
GetErrorDescription() 
should have a returnvalue like those:

Code: Select all

numerrors=GetErrorCounter() 
adress=GetErrorAdress() 
description$=GetErrorDescription() 

Posted: Thu Jul 03, 2003 7:53 am
by Insomniac
I think you need an "End" after the "Until" or your error routine is going to run every time you run your program :?:

Regards

Insomniac