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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Where <strong>LotusScript</strong> commands and syntax are like <strong>Visual</strong> <strong>Basic</strong>’s (<strong>for</strong><br />

example, the %If ... %Endif as compared to the #If ... #End If conditional<br />

compilation commands), they will need to be converted, redone or not used<br />

in order to create code that is truly portable between <strong>Visual</strong> <strong>Basic</strong> and<br />

<strong>LotusScript</strong>.<br />

Unlike <strong>Visual</strong> <strong>Basic</strong>, <strong>LotusScript</strong> is not centered around the Properties,<br />

Methods, and Events metaphor. <strong>LotusScript</strong> is built around interacting with<br />

the objects provided within the respective host application and<br />

development tools provided by Lotus. For example, objects don’t have Tags<br />

or Captions. A static text object uses a text property rather than a caption<br />

property to read and change its value. So any <strong>Visual</strong> <strong>Basic</strong> code that refers<br />

to captions <strong>for</strong> labels needs to be changed. Similarly, <strong>LotusScript</strong> doesn’t<br />

support the tag property. But <strong>LotusScript</strong> does have a Name(variable)<br />

function that returns an item’s name, which can then be used to operate on<br />

objects dynamically at runtime.<br />

Control Arrays<br />

<strong>LotusScript</strong> does not support control arrays or indexes on individual<br />

objects in the same way as <strong>Visual</strong> <strong>Basic</strong>. So your <strong>Visual</strong> <strong>Basic</strong> code that sets<br />

up an array of text objects with a common code routine — as with Sub<br />

txtAmtField_Click (amtIdx as index) — will need to be rewritten. Buttons<br />

under <strong>LotusScript</strong> are set up as individual buttons or to act as group or<br />

checkbox buttons when they are placed onto the screen.<br />

<strong>Visual</strong> <strong>Basic</strong> Environment Constants<br />

If you are using any of the new <strong>Visual</strong> <strong>Basic</strong> embedded constants, you will<br />

need to provide a translation file of codes <strong>for</strong> anything that you want to<br />

move to <strong>LotusScript</strong>. Or you can simply choose not to use the <strong>Visual</strong> <strong>Basic</strong><br />

constants in the first place. For example, you might be using things like this<br />

in <strong>Visual</strong> <strong>Basic</strong> 4 applications now:<br />

If rc = vbYes or rc = vbAbort Then<br />

' add processing here.<br />

EndIf<br />

You will need to add constant declarations <strong>for</strong> vbYes and vbAbort in code<br />

ported to <strong>LotusScript</strong>; otherwise the references to vbYes and vbAbort<br />

would prove invalid.<br />

Caution If you are not using Option Declare in your <strong>LotusScript</strong> or Option<br />

Explicit in your <strong>Visual</strong> <strong>Basic</strong> modules and move the code shown above, it<br />

may compile and give you erroneous results. Both vbYEs and vbAbort<br />

would be treated as uninitialized variables and both contain a 0. The code<br />

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

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

Saved successfully!

Ooh no, something went wrong!