contents   index   previous   next



Obtaining information about errors and exceptions

 

When you invoke an object method or set or retrieve a property, f90VB and OLE must interpret all the arguments you pass at run time. This means that many errors will not be caught by your compiler, but rather when you are running your application, and let’s face it, the value returned in iRet is not always very helpful. In addition to iRet, PropertyGet, PropertyPut, PropertySet, and ExecMethod also accept an Exception Structure as an argument. The exception structure was explained in a previous chapter, so there is not much more to say here about it. Just for the fun of it, you may want to change the name of the property in one of the PropertyPut or PropertyGet calls, to induce an error and see how the content of EInfo is modified. For example, change this line:

 

Document=PropertyGet(Word,'ActiveDocument', EInfo=EInfo, iRet=iRet)


To:

 

Document=PropertyGet(Word,'MActiveDocument', EInfo=EInfo, iRet=iRet)

 

 

This will produce an error because the object does not expose a property named MActiveDocument. Note that the program still compiles, and the new line will produce an error message which will be printed by the section below the label 1000. As you may have noticed, EInfo and iRet are optional arguments, but it is always a good idea to use them.

 

Optional and named arguments