drawArray() Tool to draw arrays

<< Click to Display Table of Contents >>

Navigation:  Printing arrays >

drawArray() Tool to draw arrays

vpxPrint offers an easy interface to draw backgrounds and arrays within a page.

 

The drawArray() function can be used to draw an array with lines and columns, bookmarks and texts.

It works with a template.

You can use drawArray() to paint any background.

 

1.Define an array template:

 

A template is an array of lines with chr(10) (~n) as delimiter.

MyTemplate =    

                "+-----------------------------------+~n"

             + "|                                   |~n"

             + "+-----------------------------------+".

Note that this array acts with standard rows and columns

settings as defined in the <CPI> and <LPI>.

 

 ... defines a box of 3 rows starting at column 1:

 

 

 

MyTemplate =

                   "+--------+--------------------------+~n"

                 + "|        |                          |~n"

+ "+--------+------+----------+--------+~n"

+ "                |          |        |~n"

+ "                +----------+--------+".

 

 

 ... defines a box, of 5 rows starting at column 1:

array

 

 

Each line break (~n) advances the cursor to the next line. The value of the line height is given by the setting of the <LPI> tag and the width of the '-' character is the <CPI> tag.

 

The characters that drawArray() uses are:

 

 

+

Describes a line collision (vertical and horizontal) or a corner: left upper, right upper, left bottom or right bottom.        

-

Horizontal line

|

Vertical line

#

Defines a bookmark        

~t

A tab (chr(9) or "~t") can be put on each line to define the line attributes. These attributes are applied on the line before drawing. Individual title characters specification width can be specified here.

Space

A space character is interpreted as a column shift. Each space character spaces the cursor right from 1 column. This can be a problem when using texts for labels because you may want to use proportional fonts and spaces must be evaluated as a standard space char in the selected font. In this case, you have to escape the space character with a '\' (see below).

Text

Any text can be written. If the text contains reserved characters like + - | # or space, you can escape with the \ character. The text may contain vpxPrint attributes like <B> or </I> etc…

 

 

Each line in the array can have his own vpxPrint attributes.

If specific title, attributes must be specified, the format of the line can be :

"<B><I>~t| Name     |   Country     |~n".

In this case "Name" and "Country" are displayed with bold and underline characters.

Attributes are put as soon as received and apply as long as no other tag is specified.

 

 

Calling drawArray():

 

As defined in the xPrint.i, the drawArray procedure has the following syntax:

 

PROCEDURE drawArray EXTERNAL "xPrint.dll" :

   DEF INPUT PARAMETER  recLength          AS LONG.

   DEF INPUT PARAMETER  inputFormat        AS CHAR.

   DEF INPUT PARAMETER  vpxPrintvalue        AS MEMPTR.

   DEF INPUT PARAMETER  starting#          AS LONG.

   DEF INPUT PARAMETER  incr#              AS LONG.

END.

 

Where:

 

         

reclength

Number of bytes of the receiving area. This area must be large enough to accommodate the vpxPrint codification. The 'reclength' value indicates the size of this area.

inputFormat

The template,

vpxPrintValue

Area where drawArray() returns the vpxPrint code. The length of this area must be specified in the 'reclength' parameter.

starting#

The starting bookmark number. Each # in the template generates a bookmark. The first bookmark starts with this value.

incr#

Bookmark increment. Each subsequent bookmark after the first one.

 

On return, the vpxPrintValue area contains the sequence to send to vpxPrint to draw the array.

 

Example 1:

DEF VAR M AS MEMPTR NO-UNDO.

DEF VAR myArray                AS CHAR NO-UNDO.

DEF VAR myLENGTH        AS INT NO-UNDO.

 

MyArray = "……

         ….

         ".

 

myLength = 32000.                // length of the output area

 

SET-SIZE(M) = myLength.

 

RUN drawArray( myLength, myArray, M, 10, 10).

 

MyBackground = GET-STRING(M, 1).

 

SET-SIZE(M) = 0.

 

If myBackground = "" THEN

         ERROR… area is not large enough…

 

Generates a background with the specified template. Bookmarks in the template are numbered from 10 by 10.

 

Example 2:

 

FUNCTION myBackGround RETURNS CHARACTER( /* parameter-definitions */ ) :

/*------------------------------------------------------------------------------

 Purpose:  

   Notes:  

------------------------------------------------------------------------------*/

DEF VAR M AS MEMPTR.

DEF VAR iBackground AS CHAR.

DEF VAR iFormat AS CHAR.

iFormat =     '                                             +-------------------------------+~n'

           + '                                             |#                              |~n'

                                 /* Defines the bookmark #10 */

           + '                                  Address... |                               |~n'

           + '                                             |                               |~n'

           + '                                             |                               |~n'

           + '                                             |                               |~n'

           + '                                             |                              #|~n'  

/* Defines the bookmark #20 */

           + '                                             +-------------------------------+~n'

           + '~n'

           + '~n'

+ '<FArial><P14><B><U>~t'        /* Attributes values for the labels. Note the ~t character */

           + '       References:~n'

+ '<P12></U></B>~t'                /* rest previous attributes                */

           + '      +------------------------------------------------------------------------+~n'

           + '      |#                                                                       |~n'

/* defines the bookmark #30 */

           + '      |                                                                        |~n'                

           + '      |                                                                       #|~n'

/* defines the bookmark #40 */

           + '      +------------------------------------------------------------------------+~n'

           + '~n'

           + '+------------+---------------------------------+---------+--------+------------+~n'

+ '<B><I>~t'

           + '|Item\ num    |Description                      |     Unit|    Qty |   Sub\ Total|~n'

+ '</B></I>~t'                /* Attributes values for the labels. Note the ~t character */

           + '+------------+---------------------------------+---------+--------+------------+~n'

           + '|#           |#                               #|      #  |      # |        #   |~n'

                               /* defines the bookmark #50,60,70,80,90,100 */

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '|            |                                 |         |        |            |~n'

           + '+------------+---------------------------------+------------------+------------+~n'

           + '                                                                  |        #   |~n'

/* defines the bookmark #110 */

           + '                                                                  +------------+~n'

           + '                                                                                ~n'

           + '             +----------------------------------+~n'

           + '             |TOTAL with 19.6% TAX          #   |~n' /* #120 */

           + '             +----------------------------------+~n'

   .

 

SET-SIZE(M) = 8192.

 

RUN drawArray(8192, iFormat, M, 10, 10).

 

iBackground = GET-STRING(M, 1).

SET-SIZE(M) = 0.

 

DEF VAR F AS CHAR NO-UNDO.

DEF VAR A   AS CHAR NO-UNDO.

 

F = SEARCH("4gl.bmp").                  /* logo path */

IF F <> ? THEN

   FILE-INFO:FILE-NAME = F.

 

A =

   "<R1><C1><#1>"

   + "<AT=+40,+40><IMAGE#1=" + FILE-INFO:FULL-PATHNAME + ">"

   + "<R1><C50><B><P20><FTahoma>My Company~n~n"

   + "<C50>my Adress<FArial><P12>"

 

   + "<R10><C1>" + iBackGround

   + "<=#20><R+1><C+1><FRAME#10>"            /* frame for address */

   + "<=#40><R+1><C+1><FRAME#30>"           /* frame for reference */

   + "<R60><C1><FROM><C80><LINE>~n"

   + "<#400><R+5><C80><FRAME#400><USE#400>"

   + "<P8><I>All rights are reserved etc... All rights are reserved etc...All rights are reserved etc... All rights are reserved etc... All rights are reserved etc..."

   + "All rights are reserved etc... All rights are reserved etc... All rights are reserved etc... All rights are reserved etc..."

   + "All rights are reserved etc... All rights are reserved etc... All rights are reserved etc... All rights are reserved etc..."

   + "All rights are reserved etc... All rights are reserved etc... All rights are reserved etc... All rights are reserved etc..."

   + "All rights are reserved etc... All rights are reserved etc... All rights are reserved etc... All rights are reserved etc..."

   + "All rights are reserved etc... All rights are reserved etc...All rights are reserved etc...All rights are reserved etc...All rights are reserved etc...<P12></I></USE>"

   .

 

 RETURN A.   /* Function return value. */

 

END FUNCTION.

 

 

Technical notes:

- Note that each line in the template uses a bookmark starting at #800. So you can specifically address the lines with this number.