Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Example LotusScript: Draw rounded rectangles to size (for envelope windows)

Last updated: before December, 1998

'Written by Jerry Sikes, 1996
   '(C) Copyright 1996 by Jerry Sikes, Unisource Conveting
   '
   'Permission is granted to freely copy this script in electronic form,
   'or to print for personal use. It may be use in any Approach database,
   'but may not be distributed for profit either by itself or as part of
   'a collection or database.
My company produces envelopes, roughly 8 million per day. Many envelopes have
windows cut into them so address, postal barcodes or other information may be
displayed. We have about 250 double window dies of various configurations.
LotusScript made it possible to accurately draw rounded rectangles of each
die, exactly to scale and proportion. The first time a die is input, we use
the the size and positional data based on that job. Approach, through
formulas, determines absolute coordinates. This is used to compare requests
for the same proportions, but perhaps a differant positioning of the die
relative to the left and bottom of an envelope. I will not get into the
search criteria used in finds. This script shows how to manipulate screen
objects locations and size. For referance, 1 inch = 1440 twips. A twip
(TWentIeth of a Point) is a measurement equal to 1/1440th of an inch. For
referance, input for each window (2 per double die) is, width, height,
distance from left edge of envelope to left edge of each die and distance
from bottom of envelope to bottom of each die as numeric 2.4. The
intersection of the left edge of the left most die and the bottom of the
lowest die become coordinates (0, 0). The coordinates for the four corners
for each window are then calculated. (X_1, X_2, X_3, X_4. Y_1, Y_2, Y_3, Y_4)

Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
        Dim ln As LINEOBJECT
        Dim rb As ROUNDRECT
        Set rb=Source.body.ObjRoundRect1
        rb.Left = 2880+(1440*Val(SOURCE.x_1.TEXT))
'The 2880 keeps the result no closer than 2 inches from the left of the form
        rb.Top = 8640-(1440*Val(source.y_1.TEXT))
'8640 is 6 inches from top
        rb.Width = 1440*Val(source.SIZE_WIDTH_1.TEXT)
        rb.Height = 1440*Val(SOURCE.SIZE_HEIGHT_1.TEXT)
        rb.NamedStyle="Default"
        rb.Background.Color.SetRGB(COLOR_CORNFLOWER)
        Set rb=Source.body.ObjRoundRect2
        rb.Left = 2880+(1440*Val(SOURCE.x_3.TEXT))
        rb.Top = 8640-(1440*Val(source.y_3.TEXT))
        rb.Width = 1440*Val(source.SIZE_WIDTH_2.TEXT)
        rb.Height = 1440*Val(SOURCE.SIZE_HEIGHT_2.TEXT)
        rb.NamedStyle="Default"
        rb.Background.Color.SetRGB(COLOR_CORNFLOWER)
        Set ln=Source.body.objLine2
        ln.Left = 2880
        Set ln=Source.body.objLine3
        ln.Top = 8640
'objLine2 & 3 are my 0,0 referance lines
        Set ln=Source.body.objLine21
        If Val(source.x_1.text)>Val(source.x_3.text) Then
                ln.Left = 2880+(1440*Val(source.x_1.text))
        Else
                ln.Left = 2880+(1440*Val(source.x_3.text))
        End If
        Set ln=Source.body.objLine31
        If Val(source.y_2.text)>Val(source.y_4.text) Then
                ln.Top = 8640-(1440*Val(source.y_2.text))
        Else
                ln.Top = 8640-(1440*Val(source.y_4.text))
        End If
'objLine21 and 31 float as necessary
End Sub

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.