Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Mastering PowerBuilder

HomePrevious Lesson: Sharing DataWindow/DataStore With a RTE Control
Next Lesson: Exercises

DataWindow Dot Notation - Error Handling

When you use the ".Object" convention, the compiler checks the syntax only till "Object". Everything following the Object property is evaluated at execution time. PowerBuilder triggers the DataWindow control's Error event whenever an error occurs in the expression at execution time. The Error event allows you to respond with error recovery logic when an expression is not valid. If you write a script for this event, you can catch an error before it triggers the SystemError event at the application object. For example:
dw_product.Object.Data[ dw_product.GetRow(),2] = &
'obsolete ' + &
dw_product.Object.Data[ dw_product.GetRow(),2]

In the above expression, we are marking a product obsolete by prefixing "obsolete" to the product_description. The above code assumes the product_description would be the second column in the DataWindow. Just for testing, replace 2 with 1 and append this code to the ue_retrieve event of the w_product_master and run the application. You won't get the compilation error and will get run-time error. Since, we wrote no code for the Error event for the dw_product DataWindow control, this error will trigger SystemError event.

The Error event has several arguments that provide information about the error condition. The first five arguments in the following listing are the same as the attributes that are available at error object.

  • errornumber
  • errortext
  • errorwindowmenu
  • errorobject
  • errorscript
  • errorline
  • action
  • returnvalue

The last two arguments Action and ReturnValue are passed by reference that allows you to affect the outcome of the event. You can specify one of the following four values for the action:

  • ExceptionFail!
  • ExceptionIgnore!
  • ExceptionRetry!
  • ExceptionSubstituteReturnValue!

The default value for action is ExceptionFail!. That means, if you don't write any code for this event, action contains ExceptionFail!. This value triggers SystemError event. You can populate ReturnValue with a value whose data type matches the expected value that the DataWindow would have returned. This value is used when the value of Action is ExceptionSubstituteReturnValue! Do not use ExceptionSubstituteReturnValue! to substitute a return value when an element in the middle of an expression causes an error. The ExceptionSubstituteReturnValue! is most useful for handling errors in data expressions.
HomePrevious Lesson: Sharing DataWindow/DataStore With a RTE Control
Next Lesson: Exercises

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com