![]() ![]() The INDIRECT function below does the trick.Įxplanation: =AVERAGE(INDIRECT("Scores")) reduces to =AVERAGE(Scores). However, the AVERAGE function below returns an error.Įxplanation: =AVERAGE("Scores") returns an error because Excel cannot calculate the average of a text string!ģ. For example, the AVERAGE function below uses the named range Scores.Įxplanation: the named range Scores refers to the range D1:D3.Ģ. Other indirection constants include:Ĭlearly there's a lot of opportunity to write generalized, reusable code with indirection.Use the INDIRECT function in Excel to convert a text string into a valid named range.ġ. The second parameter (indControl in this case) tells WinDev the type of object it's resolving. Here's an example from the tutorial that assumes you have a control called Name and a variable called CustName: = CustName Indirection allows you to build the name of a control, a file item or a variable from a string expression. It's a simple concept (it only gets a single page in the tutorial) but it really is powerful. Indirection is one of those things that keeps coming up in the discussions I have with WinDev developers, and always in the context of "man, is this cool." ![]() Interestingly, in Java the convention is the other way around - exceptions are generally situations you are expected to handle while errors are usually fatal. If you have personal experience with writing exception-based code in WinDev please post your comments! I'd also be interested to hear from anyone who habitually uses these options to implement customized error/exception handling. That seems to be the convention in WinDev, and again I don't have the WinDev experience to back up my assertions, but it seems to me that you can choose in your own code whether you want to take an error-based or exception-based approach to handling problems in program execution. While the second displays the exception handling tab:īased on these two windows you might assume that exceptions are for fatal errors and errors are for non-fatal errors. Once again this has been a bit of a diversion from the tutorial, which in this section focuses on automatic error handling.Īt the top of the code editor window you will see two links:īoth links bring up the same window, but the first displays the error handling tab: NET, and they are often a much more elegant way to handle errors in complex code.Ĭheck out the WinDev reference page on exception handling for more. I have used exceptions a lot in Java and. Your code might look like this:įull disclosure: I haven't played with any of this code yet I'm just observing that it's legal code, and that WinDev does have support for exceptions. Exceptions allow you to separate the error handling from the point at which the error occurs.įor instance, let's say you have three function calls that you have to call in sequence, and any one of them can introduce an error. NET or Java, you're probably familiar with exceptions as well. Will you terminate? Will you show a message to the user? Whatever you do, your code is responding when that error happens. If you check for it (advisable) then you have to make a decision at that point what's going to happen to program execution. You're either going to check for the error or ignore the error. Let's say you call a function, and that function returns an error code. I'm aware of two main approaches: error handling and exception handling.įor most of us, errors are more familiar than exceptions. No doubt there are many different schemes out there for handling errors. I don't mean WinDev specifically, I mean it would be so nice if all errors could be handled automagically. Picking up the tutorial after the summer publishing break, I'm at page 375, Automatic Management of Errors. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |