18.01.2013 Views

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Extending the Code<br />

<strong>Visual</strong> <strong>Basic</strong> provides the ability to Raise an error <strong>for</strong> an object, which<br />

allows you to handle the error through external applications or OLE<br />

servers. The code <strong>for</strong> this looks like this:<br />

object.Raise(Number, Source, Description, HelpFile, HelpContext)<br />

and works in a similar fashion to using the Error errNumber statement<br />

within <strong>Basic</strong> code. The system believes that the error has occurred once you<br />

issue the Error statement or .Raise method <strong>for</strong> an object, with all expected<br />

error traps enabled as well.<br />

Note that you can generate your own application-level errors in both <strong>Visual</strong><br />

<strong>Basic</strong> and <strong>LotusScript</strong>, by using the Error statement with an unused error<br />

number. For example, if you have an appropriate On Error Goto trap in a<br />

section of code, the statement ERROR 147 will generate a user-defined<br />

error in both languages.<br />

In <strong>Visual</strong> <strong>Basic</strong> you’ll receive the error string “Application-Defined or<br />

Object-Defined Error”. In <strong>LotusScript</strong> the error message generated would<br />

be “User-defined error”.<br />

This allows you to define errors that can be handled the same way, sharing<br />

the user-defined error numbers across multiple applications.<br />

Anyone developing complex applications knows that you will need more<br />

than just the BASIC language syntax itself, in order to add complex or<br />

custom processing to your program. Usually this means accessing the<br />

underlying environment’s API calls, accessing external data engines or<br />

using the many custom controls available from third-party companies.<br />

Application Programming Interface Calls<br />

Using API calls allows you to extend your programming reach into the<br />

system-oriented functions, available in the underlying operating systems.<br />

Note that once you code an API call in a language like <strong>LotusScript</strong> or <strong>Visual</strong><br />

<strong>Basic</strong>, you have added complexity as well as reliance on the presence of the<br />

underlying service. <strong>LotusScript</strong> and <strong>Visual</strong> <strong>Basic</strong> differ on how APIs are<br />

enabled in the respective languages.<br />

32-bit issues<br />

An example of this can again be found in the WriteProfileString API call. In<br />

Windows 3.1x, this API call places a string into the WIN.INI ASCII<br />

parameter file. GetProfileString can be later used to retrieve the string.<br />

Chapter 1: <strong>LotusScript</strong> and <strong>Visual</strong> <strong>Basic</strong>: A Comparison 15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!