OnError

Just starting out? Need help? Post your questions and find answers here.
dbellis
User
User
Posts: 10
Joined: Sun Jun 22, 2003 4:42 am

OnError

Post 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
Codeng Makes Your Girl Friends Hate You ;)
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

replace
OnErrorGoto(ErrorInfo)

with

OnErrorGoto(?ErrorInfo)

:)
SPAMINATOR NR.1
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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() 
SPAMINATOR NR.1
Insomniac
New User
New User
Posts: 6
Joined: Sun Apr 27, 2003 12:28 am
Location: New Zealand

Post 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
Post Reply