open-insight/SYSPROG/STPROC/OIPI_EXAMPLE2.txt
2024-03-25 15:17:34 -07:00

118 lines
5.1 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

subroutine OIPI_Example2(dummy)
/*
  Printer_Example2
 
  This is an example program on how to use the OpenInsight Printer Interface.
  This example creates a simple invoice using the Table Module.
*/
declare function Set_Printer, Get_Printer, RGB, msg
$insert OIPRINT_EQUATES
$Insert msg_equates
* Initialize the printing session with a name, dialog title, and margins
name = "Sample Invoice"
title = ""
title<1> = "Printing Sample Invoice..."
title<2> = "Example Print Preview"
margin = 1:@FM:1.75:@FM:1:@FM:1
*  Gentlemen, start your engine.
x = Set_Printer("START32")
* Display report with Print Preview Window at the last size and position
x = Set_Printer("INIT", name, title, margin, "", 4)
if x < 0 Then
unused = msg( "", "INIT ERROR = " : x )
end
*
* Set the text font and the Header/footer font
x = Set_Printer("FONTHEADFOOT", "Times New Roman":@FM:12)
font = "Arial":@FM:12:@FM:"L"
fontBold = "Arial":@FM:12:@FM:"L":@FM:1
x = Set_Printer("FONT", font)
if x < 0 Then
x = msg("", "FONTHEADFOOT Error")
end
* Set the header with the text "Sample Invoice" centered , and "Page #" aligned To the right
* margin on the first line.  The text "for the OIPI 2.0" is centered on the second line.
x = Set_Printer("HEADER", @vm:"Sample Invoice":@vm:"Page 'P'":@FM:@vm:"for the OIPI 2.0":@FM)
if x < 0 Then
x = msg("", "HEADER Error")
end
* Print a bitmap at 1 inch from the top and 1 inch from the left side of the page.
* The left and top values are calculated from the margins.  The width and height of the
* bitmap will be 0.5 by 0.5 inches, and the bitmap will print on every page.
x = Set_Printer("BMP", "PRINTER.BMP", 0:@FM:-0.75:@FM:0.5:@FM:0.5, 0, 1)
if x < 0 Then
x = msg("", "BMP Error")
end
* Set the text font to bold Arial to print the title of the Date/Invoice table. Then
* print the date and invoice number with no bold.  The first column of the table is blank
* to place the date and invoice number in the correct location on the page.  The date and
* invoice number are centered and there is no border around this table.  These tables have
* no column headers.
x = Set_Printer("FONT", fontBold)
table1 = ",Date,Invoice No."
convert "," to @vm in table1
x = Set_Printer("ADDTABLE", ">5040":@VM:"^2160":@VM:"^2160":@FM, "", table1, "", "", "", TB_NONE)
x = Set_Printer("FONT", font)
table1 = ",01 Jan 1996,340082"
convert "," to @vm in table1
x = Set_Printer("ADDTABLE", ">5040":@VM:"^2160":@VM:"^2160":@FM, "", table1, "", "", "", TB_NONE)
* Print a blank line then print the Bill To/From table.  These tables have no column
* headers.  These tables have no borders and have left justified columns.
x = Set_Printer("TEXT")
x = Set_Printer("FONT", fontBold)
table2 = "Bill To:,,Ship To:"
convert "," to @vm in table2
x = Set_Printer("ADDTABLE", "3600":@VM:"1440":@VM:"3600":@FM, "", table2, "", "", "", TB_NONE)
x = Set_Printer("FONT", font)
table2 = ""
table2<1> = "Test Company 123//Test Company (Billing Dept)"
table2<2> = "123 West Main Street//555 West Main Street, MS:123"
table2<3> = "Portland, OR  97005//Portland, OR  97005"
convert "/" to @vm in table2
x = Set_Printer("ADDTABLE", "3600":@VM:"1440":@VM:"3600":@FM, "", table2, "", "", "", TB_NONE)
* These tables have to column headers and have borders all sides of the tables. Every column
* is center justified.
x = Set_Printer("TEXT")
x = Set_Printer("FONT", fontBold)
table3 = "Terms,P.O. Number,Ship Date,Ship Via"
convert "," to @vm in table3
x = Set_Printer("ADDTABLE", "^2160":@VM:"^2160":@VM:"^2160":@VM:"^2160":@FM, "", table3, "", "", "", TB_ALL)
x = Set_Printer("FONT", font)
table3 = "Net 30,9500123,03 Jan 1996,UPS Next Day Delivery"
convert "," to @vm in table3
x = Set_Printer("ADDTABLE", "^2160":@VM:"^2160":@VM:"^2160":@VM:"^2160":@FM, "", table3, "", "", "", TB_ALL)
* The position is set to 0 inches from the left margin, and 3 inches from the top margin.  This
* will guarentee the table will always start to print from the same location.
x = Set_Printer("POS", 0:@FM:3)
* Create the dummy data for the main table.  This table has column headers, because the column
* headers need to be printed at the to of each page if the main invoice table requies more
* than one page.  The rows will have borders.
tableHead = "Quantity,Description,Unit Price,Ext Price"
table = ""
table<1> = "1,OpenInsight Printer Interface 2.0 -- Special limited time introductory price,$345.00,$345.00"
table<2> = "2,Second line item here,$1.00,$2.00"
table<3> = "1,Third line item here (no charge for this bonus item),$0.00,$0.00"
for i = 4 to 30
table<i> = "1,Test line item here":(i-3):",$0.00,$0.00"
next i
table<31> = ""
table<32> = ",Merchandise Total,,$347.00"
table<33> = ""
table<34> = ",Tax,,$12.00"
table<35> = ",Shipping,,$5.00"
table<36> = ",Handling,,$5.00"
table<37> = ""
table<38> = ",,Sub Total,$369.00"
table<39> = ""
table<40> = ",,Total,$369.00"
convert "," to @vm in table
convert "," to @vm in tableHead
x = Set_Printer("ADDTABLE", ">1080":@VM:"<4680":@VM:">1440":@VM:">1440":@FM, tableHead, table, RGB(192, 192, 192), "", "", TB_BOX_ROWS)
* Finish this prining session.
x = Set_Printer("TERM", 1)
return