SATFORM Examples
S@
Home SATGUI SATSHELL SATFORM SATFILTER SATREPORT SATMYSQL License Download Examples Contact

An "Invoice" letter. The source data for this letter is a MySQL database formatted using SATMYSQL.

This example uses bold/italic attributes. Font style and size. Special character. Variable and Predefined data (unmodified and using mixed case conversion). Positioning text. Positioning numbers using right justification. Box drawing.

Sample Output

Example SAT/ML

Assume a file called invoice in the $SATHOME/form directory with the following contents:

<body>
<dateformat uk>
<insert boxes>
<font univers:20>
<b>INVOICE</b><size 12>
<indent 10>





%{title} %{first_name} %{last_name} <@ 50><b>Invoice:</b><@ 60>${invoice}
${house} %{street}
%{city}<@ 50><b>Customer:</b><@ 60>${customer}

<@ 50><b>Date:</b><@ 60>${DATE}








<b>Code<@ 22>Description<@ 62>Price (!L:)</b>

<repeat 20:<field 1:${item-%}><@ 22><field 2:${item-%}><$ 68:<field 3:${item-%}>>>
<@ 8:47>This invoice <i>must</i> be paid within 30 days.<b><$ 68:${total}></b>
</body>

<label boxes>
<@ 0:5>
<indent 8>
<box>
(----------------------)
|                      |
|                      |
|                      |
|                      |
|                      |
|                      |
|                      |
[----------------------]





(-----------:---------------------------------------:------------)
|           |                                       |            |
,-----------+---------------------------------------+------------.
<repeat 20:|           |                                       |            |>
[-----------;---------------------------------------+------------.
                                                    |            |
                                                    |            |
                                                    |            |
                                                    [------------]
</box>
<@ 0:0>
</label>
Example Database

Assume a MySQL database called orderdb with the following contents/structure:

mysql> select * from customer;
+----------+-------+------------+-----------+-------+--------------------+------------+
| customer | title | first_name | last_name | house | street             | city       |
+----------+-------+------------+-----------+-------+--------------------+------------+
| FS001    | MR    | FRED       | SMITH     | 49    | GREENFIELDS STREET | RIVER CITY |
| FS002    | MISS  | MARY       | JOHNSON   | 2314  | GLADEVIEW AVENUE   | RIVER CITY |
+----------+-------+------------+-----------+-------+--------------------+------------+
2 rows in set (0.00 sec)

mysql> select * from invoice;
+---------+----------+--------+
| invoice | customer | code   |
+---------+----------+--------+
|    0123 | FS001    | 020034 |
|    0123 | FS001    | 097762 |
|    0123 | FS001    | 002157 |
|    0124 | FS002    | 097761 |
|    0124 | FS002    | 097759 |
+---------+----------+--------+
5 rows in set (0.00 sec)

mysql> select * from product;
+--------+-----------------------------+--------+
| code   | description                 | price  |
+--------+-----------------------------+--------+
| 020034 | Small widget with flange    | 102.47 |
| 097762 | Size 4 bolt                 |   1.98 |
| 002157 | Washer for small widget     |   2.40 |
| 020033 | Small widget without flange |  92.17 |
| 097761 | Size 3 bolt                 |   1.80 |
| 097760 | Size 2 bolt                 |   1.62 |
| 097759 | Size 1 bolt                 |   1.43 |
+--------+-----------------------------+--------+
7 rows in set (0.00 sec)

Example Script to Format Data From Database

The following (SATMYSQL) script, when called as a SATGUI process, will print an "Invoice" letter for the invoice identified by parameter ${4}.

#!/usr/bin/ksh
{ mysql -v -v orderdb 2>&1 << !SQL
select 'satmysql print continue';
select distinct
       c.customer,
       c.title,
       c.first_name,
       c.last_name,
       c.house,
       c.street,
       c.city,
       i.invoice
from   customer c, invoice i
where  i.invoice='${4}' and
       c.customer=i.customer;
select 'satmysql print continue';
select sum(p.price) as total
from   invoice i, product p
where  i.invoice='${4}' and
       i.code=p.code;
select 'satmysql print item';
select p.code,
       p.description,
       p.price
from   invoice i, product p
where  i.invoice='${4}' and
       i.code=p.code;
!SQL
} | satmysql | satform invoice | lp -d${3} -onobanner -s


Copyright © 2003 Adrian Davis.