optimize code
Posted: Sun Dec 04, 2016 5:21 am
Hi Roger,
here is part from one my complex dialog screen, which works ok,
but I want/need make it „dynamic and generic“, little optimize also and use only locals variables(if it is possible)...
As reference I use your Invoice.prg from directory samples, where I started make some changes, but I cannot make it like I need...
I want only allow edit Quantity field and in added column Sum I want show summary Quantity and Price
Also I want change value in Get with Fn or Ctrl_Fn keys and refresh Sum column
Differences with your code (Added/Removed parts) are marked.
Please, can you help me with this?
In my current „hard-writed“ prg code all work like I need, but I don‘t know how do it in your version with locals variables.
TIA
Zdeno
here is part from one my complex dialog screen, which works ok,
but I want/need make it „dynamic and generic“, little optimize also and use only locals variables(if it is possible)...
Code: Select all
Local nDospely := 0
Local nStudent := 0
*
Local nCL_Dospely := 0
Local nCL_Student := 0
*
Local bS_L_Dospely := { || nCL_Dospely }
Local bS_L_Student := { || nCL_Student }
*
Local bS_CL_Dospely := { || ( nDospely * nCL_Dospely ) }
Local bS_CL_Student := { || ( nStudent * nCL_Student ) }
* variables are filled later by functions, codeblocks and/or users/operators via DCGET...
nRow++
@ nRow, 1 DCSAY 'Dospelý - F1' SAYSIZE 14 SAYID 'SAY_DOSPELY' SAYRIGHT PARENT oSt_Vst
@ nRow,18 DCGET nDospely PICTURE '99' GETID 'GET_DOSPELY' /*GETOBJECT oDospely*/ RANGE 0,99 ;
VALID { || TestKV( ( nDospely + nStudent + nDochodca + nZajazd + nDieta + nDieta + nVolna ), nVolne ) } ;
WHEN { || _lNova .and. ! M->plUzavrete .and. M->plSkupExist } ;
LOSTFOCUS { || DC_GETREFRESH( GetList, nil, DCGETREFRESH_ID_EXCLUDE, { 'GET_EXPO_CISLO', 'GET_CAS', 'BROWSER' } ) } PARENT oSt_Vst
@ nRow,24 DCGET bS_L_Dospely WHEN { || .F. } PICT '999.99' GETSIZE 8,1.2 NOTABSTOP GETID obS_L_Dospely PARENT oSt_Vst
@ nRow,33 DCGET bS_CL_Dospely EDITPROTECT { || .T. } PICT '999.99' GETSIZE 8,1.2 NOTABSTOP COLOR GRA_CLR_BLUE, GRA_CLR_BACKGROUND ;
LOSTFOCUS { || SetAppFocus( oDospely ) } PARENT oSt_Vst
nRow++
@ nRow, 1 DCSAY 'Študent - F2' SAYSIZE 14 SAYID 'SAY_STUDENT' SAYRIGHT PARENT oSt_Vst
@ nRow,18 DCGET nStudent PICTURE '99' GETID 'GET_STUDENT' /*GETOBJECT oStudent*/ RANGE 0,99 ;
VALID { || TestKV( ( nDospely + nStudent + nDochodca + nZajazd + nDieta + nVolna ), nVolne ) } ;
WHEN { || _lNova .and. ! M->plUzavrete .and. M->plSkupExist } ;
LOSTFOCUS { || DC_GETREFRESH( GetList, nil, DCGETREFRESH_ID_EXCLUDE, { 'GET_EXPO_CISLO', 'GET_CAS', 'BROWSER' } ) } PARENT oSt_Vst
@ nRow,24 DCGET bS_L_Student WHEN { || .F. } PICT '999.99' GETSIZE 8,1.2 PARENT oSt_Vst
@ nRow,33 DCGET bS_CL_Student EDITPROTECT { || .T. } PICT '999.99' GETSIZE 8,1.2 NOTABSTOP COLOR GRA_CLR_BLUE, GRA_CLR_BACKGROUND ;
LOSTFOCUS { || SetAppFocus( oStudent ) } PARENT oSt_Vst
DCHOTKEY xbeK_F1 ;
ACTION {|o| IIf( ! M->plUzavrete .and. M->plSkupExist, ;
( o := DC_GetObject(GetList,'GET_DOSPELY'), ;
IIf( ( nDospely <= 98 ), nDospely++, NIL ), o:setData(), ;
DC_GETREFRESH( GetList, nil, DCGETREFRESH_ID_EXCLUDE, { 'GET_EXPO_CISLO', 'GET_CAS', 'BROWSER' } ), ;
SetAppFocus( o ) ), ;
NIL ) }
DCHOTKEY xbeK_CTRL_F1 ;
ACTION {|o| IIf( ! M->plUzavrete .and. M->plSkupExist, ;
( o := DC_GetObject(GetList,'GET_DOSPELY'), ;
IIf( ( nDospely >= 1 ), nDospely--, NIL ), o:setData(), ;
DC_GETREFRESH( GetList, nil, DCGETREFRESH_ID_EXCLUDE, { 'GET_EXPO_CISLO', 'GET_CAS', 'BROWSER' } ), ;
SetAppFocus( o )), ;
NIL ) }
DCHOTKEY xbeK_F2 ;
ACTION {|o| IIf( ! M->plUzavrete .and. M->plSkupExist, ;
( o := DC_GetObject(GetList,'GET_STUDENT'), ;
IIf( ( nStudent <= 98 ), nStudent++, NIL ), o:setData(), ;
DC_GETREFRESH( GetList, nil, DCGETREFRESH_ID_EXCLUDE, { 'GET_EXPO_CISLO', 'GET_CAS', 'BROWSER' } ), ;
SetAppFocus( o ) ), ;
NIL ) }
DCHOTKEY xbeK_CTRL_F2 ;
ACTION {|o| IIf( ! M->plUzavrete .and. M->plSkupExist, ;
( o := DC_GetObject(GetList,'GET_STUDENT'), ;
IIf( ( nStudent >= 1 ), nStudent--, NIL ), o:setData(), ;
DC_GETREFRESH( GetList, nil, DCGETREFRESH_ID_EXCLUDE, { 'GET_EXPO_CISLO', 'GET_CAS', 'BROWSER' } ), ;
SetAppFocus( o ) ), ;
NIL ) }
As reference I use your Invoice.prg from directory samples, where I started make some changes, but I cannot make it like I need...
I want only allow edit Quantity field and in added column Sum I want show summary Quantity and Price
Also I want change value in Get with Fn or Ctrl_Fn keys and refresh Sum column
Differences with your code (Added/Removed parts) are marked.
Code: Select all
/*
This is a generic Invoice Form designed for printing with
the DCPRINT system. All invoice data is passed to the
function PrintInvoice() in a multi-dimensional array.
*/
#INCLUDE "dcprint.ch"
#INCLUDE "dcdialog.ch"
#INCLUDE "common.CH"
#include "APPEVENT.CH" && added
#define INVOICE_LOGO 1
#define INVOICE_FROM_NAME 2
#define INVOICE_FROM_ADDR1 3
#define INVOICE_FROM_ADDR2 4
#define INVOICE_FROM_CITY 5
#define INVOICE_FROM_STATE 6
#define INVOICE_FROM_ZIP 7
#define INVOICE_FROM_COUNTRY 8
#define INVOICE_FROM_TAXID 9
#define INVOICE_FROM_PHONE 10
#define INVOICE_FROM_FAX 11
#define INVOICE_FROM_EMAIL 12
#define INVOICE_REMIT_NAME 13
#define INVOICE_REMIT_ADDR1 14
#define INVOICE_REMIT_ADDR2 15
#define INVOICE_REMIT_CITY 16
#define INVOICE_REMIT_STATE 17
#define INVOICE_REMIT_ZIP 18
#define INVOICE_REMIT_COUNTRY 19
#define INVOICE_ACCT_NO 20
#define INVOICE_BILL_NAME 21
#define INVOICE_BILL_ADDR1 22
#define INVOICE_BILL_ADDR2 23
#define INVOICE_BILL_CITY 24
#define INVOICE_BILL_STATE 25
#define INVOICE_BILL_ZIP 26
#define INVOICE_BILL_COUNTRY 27
#define INVOICE_BILL_CONTACT 28
#define INVOICE_SHIP_NAME 29
#define INVOICE_SHIP_ADDR1 30
#define INVOICE_SHIP_ADDR2 31
#define INVOICE_SHIP_CITY 32
#define INVOICE_SHIP_STATE 33
#define INVOICE_SHIP_ZIP 34
#define INVOICE_SHIP_COUNTRY 35
#define INVOICE_SHIP_PHONE 36
#define INVOICE_SHIP_FAX 37
#define INVOICE_SHIP_EMAIL 38
#define INVOICE_SHIP_CONTACT 39
#define INVOICE_NUMBER 40
#define INVOICE_DATE 41
#define INVOICE_SALESMAN 42
#define INVOICE_PO_NO 43
#define INVOICE_SO_NO 44
#define INVOICE_ORDER_DATE 45
#define INVOICE_SHIP_VIA 46
#define INVOICE_TERMS 47
#define INVOICE_SHIP_DATE 48
#define INVOICE_NONTAXABLE 49
#define INVOICE_TAXABLE 50
#define INVOICE_SALESTAX 51
#define INVOICE_FREIGHT 52
#define INVOICE_MISC 53
#define INVOICE_TOTAL 54
#define INVOICE_COMMENTS 55
#define INVOICE_TAXRATE 56
#define INVOICE_ITEMS 57
#define INVOICE_ARRAY_SIZE 57
#define INVOICE_ITEM_PARTNO 1
#define INVOICE_ITEM_DESC 2
#define INVOICE_ITEM_QTY_ORD 3
#define INVOICE_ITEM_QTY_SHIP 4
#define INVOICE_ITEM_QTY_BO 5
#define INVOICE_ITEM_UI 6
#define INVOICE_ITEM_UPRICE 7
#define INVOICE_ITEM_AMOUNT 8
#define INVOICE_ITEM_TAXABLE 9
#define INVOICE_ITEM_SUM 10 && Added
#define INVOICE_ITEM_HOTKEY 11 && Added
#define INVOICE_ITEM_HOTKEY_P 12 && Added
#define INVOICE_ITEM_HOTKEY_M 13 && Added
* #define INVOICE_ITEM_ARRAY_SIZE 9 && Removed
#define INVOICE_ITEM_ARRAY_SIZE 13 && Added
#define HOTKEYS_ITEM_1 1 && Added
#define HOTKEYS_ITEM_2 2 && Added
#define HOTKEYS_ITEM_3 3 && Added
#define HOTKEYS_ITEM_4 4 && Added
#define HOTKEYS_ITEM_5 5 && Added
#define HOTKEYS_ITEM_6 6 && Added
#define HOTKEYS_ITEM_7 7 && Added
#define HOTKEYS_ITEM_8 8 && Added
#define HOTKEYS_ITEM_9 9 && Added
#define HOTKEYS_ITEM_10 10 && Added
#define HOTKEYS_ITEM_11 11 && Added
#define HOTKEYS_ITEM_12 12 && Added
#define HOTKEYS_ITEM_ARRAY_SIZE 12 && Added
/*
Specifications for aData :
Element Description
-------- -------------------------------------------------------------
INVOICE_LOGO Logo ( resource, .JPG/.GIF file name, or XbpBitMap() object
INVOICE_FROM_NAME From: Name
INVOICE_FROM_ADDR1 From: Address Line 1
INVOICE_FROM_ADDR2 From: Address Line 2
INVOICE_FROM_CITY From: City
INVOICE_FROM_STATE From: State
INVOICE_FROM_ZIP From: Zip
INVOICE_FROM_COUNTRY From: Country
INVOICE_FROM_TAXID From: Tax ID
INVOICE_FROM_PHONE From: Telephone
INVOICE_FROM_FAX From: Fax
INVOICE_FROM_EMAIL From: Email
INVOICE_REMIT_NAME Remit to: Name
INVOICE_REMIT_ADDR1 Remit to: Address Line 1
INVOICE_REMIT_ADDR2 Remit to: Address Line 2
INVOICE_REMIT_CITY Remit to: City
INVOICE_REMIT_STATE Remit to: State
INVOICE_REMIT_ZIP Remit to: Zip
INVOICE_REMIT_COUNTRY Remit to: Country
INVOICE_ACCT_NO Customer Account Number
INVOICE_BILL_NAME Bill to: Name
INVOICE_BILL_ADDR1 Bill to: Address Line 1
INVOICE_BILL_ADDR2 Bill to: Address Line 2
INVOICE_BILL_CITY Bill to: City
INVOICE_BILL_STATE Bill to: State
INVOICE_BILL_ZIP Bill to: Zip
INVOICE_BILL_COUNTRY Bill to: Country
INVOICE_BILL_CONTACT Bill to: Contact Person
INVOICE_SHIP_NAME Ship to: Name
INVOICE_SHIP_ADDR1 Ship to: Address Line 1
INVOICE_SHIP_ADDR2 Ship to: Address Line 2
INVOICE_SHIP_CITY Ship to: City
INVOICE_SHIP_STATE Ship to: State
INVOICE_SHIP_ZIP Ship to: Zip
INVOICE_SHIP_COUNTRY Ship to: Country
INVOICE_SHIP_PHONE Ship to: Phone
INVOICE_SHIP_FAX Ship to: Fax
INVOICE_SHIP_EMAIL Ship to: Email
INVOICE_SHIP_CONTACT Ship to: Contact Person
INVOICE_NUMBER Invoice Number
INVOICE_DATE Invoice Date
INVOICE_SALESMAN Salesman
INVOICE_PO_NO Purchase Order Number
INVOICE_SO_NO Sales Order Number
INVOICE_ORDER_DATE Order Date
INVOICE_SHIP_VIA Shipped Via
INVOICE_TERMS Terms
INVOICE_SHIP_DATE Ship Date
INVOICE_NONTAXABLE Non-Taxable Total
INVOICE_TAXABLE Taxable Total
INVOICE_SALESTAX Sales Tax Total
INVOICE_FREIGHT Freight Total
INVOICE_MISC Misc Total
INVOICE_TOTAL Invoice Total
INVOICE_COMMENTS Comments
INVOICE_TAXRATE Sales Tax Rate
INVOICE_ITEMS Line Items sub array (see separate specification)
Specifications for Line Items array :
Element Description
-------- ------------------------------------------------------------
INVOICE_ITEM_PARTNO Part Number
INVOICE_ITEM_DESC Description
INVOICE_ITEM_QTY_ORD Quantity Ordered
INVOICE_ITEM_QTY_SHIP Quantity Shipped
INVOICE_ITEM_QTY_BO Quantity Backordered
INVOICE_ITEM_UI Unit of Issue
INVOICE_ITEM_UPRICE Unit Price
INVOICE_ITEM_AMOUNT Amount
*/
MEMVAR aInvoice
FUNCTION Main()
LOCAL i, GetList[0], aData[INVOICE_ARRAY_SIZE], aItems[10], GetOptions, ;
nRow, nCol, oTabPage1, oTabPage2, oTabPage3, oTabPage4, lStatus, ;
cAcrobatVersion, aAcrobat, cPDFDriver, ;
aHotKeys[HOTKEYS_ITEM_ARRAY_SIZE], ; && added
cValid, bValid, ; && added
nHotKeyK_P, nHotKeyK_M, ; && added
cHotKeyK_P, bHotKeyK_P, cHotKeyK_M, bHotKeyK_M && added
aHotKeys[HOTKEYS_ITEM_1] := { 'F1' , xbeK_F1 , xbeK_CTRL_F1 } && added
aHotKeys[HOTKEYS_ITEM_2] := { 'F2' , xbeK_F2 , xbeK_CTRL_F2 } && added
aHotKeys[HOTKEYS_ITEM_3] := { 'F3' , xbeK_F3 , xbeK_CTRL_F3 } && added
aHotKeys[HOTKEYS_ITEM_4] := { 'F4' , xbeK_F4 , xbeK_CTRL_F4 } && added
aHotKeys[HOTKEYS_ITEM_5] := { 'F5' , xbeK_F5 , xbeK_CTRL_F5 } && added
aHotKeys[HOTKEYS_ITEM_6] := { 'F6' , xbeK_F6 , xbeK_CTRL_F6 } && added
aHotKeys[HOTKEYS_ITEM_7] := { 'F7' , xbeK_F7 , xbeK_CTRL_F7 } && added
aHotKeys[HOTKEYS_ITEM_8] := { 'F8' , xbeK_F8 , xbeK_CTRL_F8 } && added
aHotKeys[HOTKEYS_ITEM_9] := { 'F9' , xbeK_F9 , xbeK_CTRL_F9 } && added
aHotKeys[HOTKEYS_ITEM_10] := { 'F10', xbeK_F10, xbeK_CTRL_F10 } && added
aHotKeys[HOTKEYS_ITEM_11] := { 'F11', xbeK_F11, xbeK_CTRL_F11 } && added
aHotKeys[HOTKEYS_ITEM_12] := { 'F12', xbeK_F12, xbeK_CTRL_F12 } && added
cAcrobatVersion := GetEnv('ACROBAT_VERSION')
IF Empty(cAcrobatVersion)
cAcrobatVersion := '5'
ENDIF
IF AScan(XbpPrinter():new():list(),{|c|Upper(c)=='BULLZIP PDF PRINTER'}) > 0
cPDFDriver := 'Bullzip PDF Printer'
ELSE
cPDFDriver := 'Win2PDF'
ENDIF
DC_GroupBoxFix(.t.)
aAcrobat := DC_PrintPreviewAcrobatOpt()
aAcrobat[1] := 1 // Modal
aAcrobat[2] := AppDeskTop() // Parent
aAcrobat[3] := cAcrobatVersion
aAcrobat[6] := .T. // Ok/Cancel buttons
aAcrobat[7] := cPDFDriver
// aAcrobat[8] := 3 // Use Runshell to Call Acrobat
aAcrobat[8] := 3 // Use Acrobat ActiveX control to Call Acrobat
DC_PrintPreviewAcrobatOpt(aAcrobat)
* IF File('INVOICE.XPF') && removed
IF .t. == .f. && added
PRIVATE aInvoice
RESTORE FROM INVOICE.XPF
aData := M->aInvoice
aItems := M->aInvoice[INVOICE_ITEMS]
ELSE
aData[INVOICE_LOGO] := Pad('DONNAY.JPG',40)
aData[INVOICE_FROM_NAME] := Pad('Donnay Software Designs',40)
aData[INVOICE_FROM_ADDR1] := Pad('1632 Riverstone Ln #301',40)
aData[INVOICE_FROM_ADDR2] := Space(40)
aData[INVOICE_FROM_CITY] := Pad('Boise',30)
aData[INVOICE_FROM_STATE] := Pad('ID',15)
aData[INVOICE_FROM_ZIP] := Pad('83706',10)
aData[INVOICE_FROM_COUNTRY] := Pad('U.S.A.',20)
aData[INVOICE_FROM_TAXID] := Pad('33-567982',15)
aData[INVOICE_FROM_PHONE] := Pad('208-331-2516',15)
aData[INVOICE_FROM_FAX] := Pad('208-331-2621',15)
aData[INVOICE_FROM_EMAIL] := Pad('acctsrec@donnay-software.com',40)
aData[INVOICE_REMIT_NAME] := aData[INVOICE_FROM_NAME]
aData[INVOICE_REMIT_ADDR1] := aData[INVOICE_FROM_ADDR1]
aData[INVOICE_REMIT_ADDR2] := aData[INVOICE_FROM_ADDR2]
aData[INVOICE_REMIT_CITY] := aData[INVOICE_FROM_CITY]
aData[INVOICE_REMIT_STATE] := aData[INVOICE_FROM_STATE]
aData[INVOICE_REMIT_ZIP] := aData[INVOICE_FROM_ZIP]
aData[INVOICE_REMIT_COUNTRY] := aData[INVOICE_FROM_COUNTRY]
aData[INVOICE_ACCT_NO] := Space(10)
aData[INVOICE_BILL_NAME] := Space(40)
aData[INVOICE_BILL_ADDR1] := Space(40)
aData[INVOICE_BILL_ADDR2] := Space(40)
aData[INVOICE_BILL_CITY] := Space(30)
aData[INVOICE_BILL_STATE] := Space(15)
aData[INVOICE_BILL_ZIP] := Space(10)
aData[INVOICE_BILL_COUNTRY] := Space(20)
aData[INVOICE_BILL_CONTACT] := Space(30)
aData[INVOICE_SHIP_NAME] := Space(40)
aData[INVOICE_SHIP_ADDR1] := Space(40)
aData[INVOICE_SHIP_ADDR2] := Space(40)
aData[INVOICE_SHIP_CITY] := Space(30)
aData[INVOICE_SHIP_STATE] := Space(15)
aData[INVOICE_SHIP_ZIP] := Space(10)
aData[INVOICE_SHIP_COUNTRY] := Space(20)
aData[INVOICE_SHIP_PHONE] := Space(25)
aData[INVOICE_SHIP_FAX] := Space(25)
aData[INVOICE_SHIP_EMAIL] := Space(40)
aData[INVOICE_SHIP_CONTACT] := Space(30)
aData[INVOICE_NUMBER] := Space(10)
aData[INVOICE_DATE] := Date()
aData[INVOICE_SALESMAN] := Pad('RDONNAY',10)
aData[INVOICE_PO_NO] := Space(10)
aData[INVOICE_SO_NO] := Space(10)
aData[INVOICE_ORDER_DATE] := Date()-10
aData[INVOICE_SHIP_VIA] := Pad('FedEx 2-Day',15)
aData[INVOICE_TERMS] := Pad('Net-30',15)
aData[INVOICE_SHIP_DATE] := Date()
aData[INVOICE_NONTAXABLE] := 0
aData[INVOICE_TAXABLE] := 0
aData[INVOICE_SALESTAX] := 0
aData[INVOICE_FREIGHT] := 0
aData[INVOICE_MISC] := 0
aData[INVOICE_TOTAL] := 0
aData[INVOICE_COMMENTS] := ''
aData[INVOICE_TAXRATE] := 0
FOR i := 1 TO Len(aItems)
aItems[i] := Array(INVOICE_ITEM_ARRAY_SIZE)
* aItems[i,INVOICE_ITEM_PARTNO] := Space(15) && removed
aItems[i,INVOICE_ITEM_PARTNO] := ( 'item-' + AS( i ) ) && added
aItems[i,INVOICE_ITEM_DESC] := Space(50)
aItems[i,INVOICE_ITEM_QTY_ORD] := 0
aItems[i,INVOICE_ITEM_QTY_SHIP] := 0
aItems[i,INVOICE_ITEM_QTY_BO] := 0
aItems[i,INVOICE_ITEM_UI] := 'EA '
* aItems[i,INVOICE_ITEM_UPRICE] := 0 && removed
aItems[i,INVOICE_ITEM_UPRICE] := i && Added
aItems[i,INVOICE_ITEM_AMOUNT] := 0
aItems[i,INVOICE_ITEM_TAXABLE] := .t.
aItems[i,INVOICE_ITEM_SUM] := 0 && Added
aItems[i,INVOICE_ITEM_HOTKEY] := aHotKeys[i,1] && Added
aItems[i,INVOICE_ITEM_HOTKEY_P] := aHotKeys[i,2] && Added
aItems[i,INVOICE_ITEM_HOTKEY_M] := aHotKeys[i,3] && Added
NEXT
wtf aItems && Added
ENDIF
* @ 0,0 DCTABPAGE oTabPage1 CAPTION 'General' SIZE 93,24 ; && removed
@ 0,0 DCTABPAGE oTabPage1 CAPTION 'General' SIZE 120,24 ; && added
GOTFOCUS {||UpdateTotals(aData,aItems),DC_GetRefresh(GetList)}
@ 0,0 DCTABPAGE oTabPage2 CAPTION 'From' RELATIVE oTabPage1
@ 0,0 DCTABPAGE oTabPage3 CAPTION 'To' RELATIVE oTabPage2
@ 0,0 DCTABPAGE oTabPage4 CAPTION 'Items' RELATIVE oTabPage3
DCSETPARENT TO oTabPage1
nRow := 2
nCol := 2
@ nRow++,nCol DCSAY 'Invoice Number' GET aData[INVOICE_NUMBER]
@ nRow++,nCol DCSAY 'Date' GET aData[INVOICE_DATE] POPUP {|d|DC_PopDate(d)}
@ nRow++,nCol DCSAY 'Salesman' GET aData[INVOICE_SALESMAN]
@ nRow++,nCol DCSAY 'P.O. Number' GET aData[INVOICE_PO_NO]
@ nRow++,nCol DCSAY 'S.O. Number' GET aData[INVOICE_SO_NO]
@ nRow++,nCol DCSAY 'Order Date' GET aData[INVOICE_ORDER_DATE] POPUP {|d|DC_PopDate(d)}
@ nRow++,nCol DCSAY 'Shipped Via' GET aData[INVOICE_SHIP_VIA]
@ nRow++,nCol DCSAY 'Terms' GET aData[INVOICE_TERMS]
@ nRow++,nCol DCSAY 'Ship Date' GET aData[INVOICE_SHIP_DATE] POPUP {|d|DC_PopDate(d)}
@ nRow++,nCol DCSAY 'Non-Taxable' GET aData[INVOICE_NONTAXABLE] PICT '999999.99' WHEN {||.f.}
@ nRow++,nCol DCSAY 'Taxable' GET aData[INVOICE_TAXABLE] PICT '999999.99' WHEN {||.f.}
@ nRow++,nCol DCSAY 'Tax Rate' GET aData[INVOICE_TAXRATE] PICT '9.9999'
@ nRow++,nCol DCSAY 'Sales Tax' GET aData[INVOICE_SALESTAX] PICT '999999.99' WHEN {||.f.}
@ nRow++,nCol DCSAY 'Freight' GET aData[INVOICE_FREIGHT] PICT '999999.99'
@ nRow++,nCol DCSAY 'Misc Amount' GET aData[INVOICE_MISC] PICT '999999.99'
@ nRow++,nCol DCSAY 'Total Amount' GET aData[INVOICE_TOTAL] PICT '999999.99' WHEN {||.f.}
@ nRow++,nCol DCSAY 'Comments' COLOR GRA_CLR_BLUE FONT '10.Courier Bold'
@ nRow++,nCol DCMULTILINE aData[INVOICE_COMMENTS] SIZE 80,4 FONT '8.Courier'
DCSETPARENT TO oTabPage2
nRow := 2
@ nRow++,nCol DCSAY 'Logo File' GET aData[INVOICE_LOGO] POPUP {|c|DC_PopFile(c)}
@ nRow++,nCol DCSAY 'Name' GET aData[INVOICE_FROM_NAME]
@ nRow++,nCol DCSAY 'Address 1' GET aData[INVOICE_FROM_ADDR1]
@ nRow++,nCol DCSAY 'Address 2' GET aData[INVOICE_FROM_ADDR2]
@ nRow++,nCol DCSAY 'City' GET aData[INVOICE_FROM_CITY]
@ nRow++,nCol DCSAY 'State' GET aData[INVOICE_FROM_STATE]
@ nRow++,nCol DCSAY 'Zip' GET aData[INVOICE_FROM_ZIP]
@ nRow++,nCol DCSAY 'Country' GET aData[INVOICE_FROM_COUNTRY]
@ nRow++,nCol DCSAY 'Tax ID' GET aData[INVOICE_FROM_TAXID]
@ nRow++,nCol DCSAY 'Phone' GET aData[INVOICE_FROM_PHONE]
@ nRow++,nCol DCSAY 'Fax' GET aData[INVOICE_FROM_FAX]
@ nRow++,nCol DCSAY 'E-Mail' GET aData[INVOICE_FROM_EMAIL]
nRow++
@ nRow++,nCol+2 DCSAY 'Remit to:' SAYLEFT COLOR GRA_CLR_BLUE FONT '10.Courier'
@ nRow++,nCol DCSAY 'Name' GET aData[INVOICE_REMIT_NAME]
@ nRow++,nCol DCSAY 'Address 1' GET aData[INVOICE_REMIT_ADDR1]
@ nRow++,nCol DCSAY 'Address 2' GET aData[INVOICE_REMIT_ADDR2]
@ nRow++,nCol DCSAY 'City' GET aData[INVOICE_REMIT_CITY]
@ nRow++,nCol DCSAY 'State' GET aData[INVOICE_REMIT_STATE]
@ nRow++,nCol DCSAY 'Zip' GET aData[INVOICE_REMIT_ZIP]
@ nRow++,nCol DCSAY 'Country' GET aData[INVOICE_REMIT_COUNTRY]
DCSETPARENT TO oTabPage3
nRow := 2
@ nRow++,nCol+2 DCSAY 'Bill to:' COLOR GRA_CLR_BLUE FONT '10.Courier'
@ nRow++,nCol DCSAY 'Name' GET aData[INVOICE_BILL_NAME]
@ nRow++,nCol DCSAY 'Address 1' GET aData[INVOICE_BILL_ADDR1]
@ nRow++,nCol DCSAY 'Address 2' GET aData[INVOICE_BILL_ADDR2]
@ nRow++,nCol DCSAY 'City' GET aData[INVOICE_BILL_CITY]
@ nRow++,nCol DCSAY 'State' GET aData[INVOICE_BILL_STATE]
@ nRow++,nCol DCSAY 'Zip' GET aData[INVOICE_BILL_ZIP]
@ nRow++,nCol DCSAY 'Country' GET aData[INVOICE_BILL_COUNTRY]
@ nRow++,nCol DCSAY 'Contact' GET aData[INVOICE_BILL_CONTACT]
nRow++
@ nRow++,nCol+2 DCSAY 'Ship to:' COLOR GRA_CLR_BLUE FONT '10.Courier'
@ nRow++,nCol DCSAY 'Name' GET aData[INVOICE_SHIP_NAME]
@ nRow++,nCol DCSAY 'Address 1' GET aData[INVOICE_SHIP_ADDR1]
@ nRow++,nCol DCSAY 'Address 2' GET aData[INVOICE_SHIP_ADDR2]
@ nRow++,nCol DCSAY 'City' GET aData[INVOICE_SHIP_CITY]
@ nRow++,nCol DCSAY 'State' GET aData[INVOICE_SHIP_STATE]
@ nRow++,nCol DCSAY 'Zip' GET aData[INVOICE_SHIP_ZIP]
@ nRow++,nCol DCSAY 'Country' GET aData[INVOICE_SHIP_COUNTRY]
@ nRow++,nCol DCSAY 'Phone' GET aData[INVOICE_SHIP_PHONE]
@ nRow++,nCol DCSAY 'Fax' GET aData[INVOICE_SHIP_FAX]
@ nRow++,nCol DCSAY 'Contact' GET aData[INVOICE_SHIP_CONTACT]
DCSETPARENT TO oTabPage4
nRow := 2
@ nRow, 2 DCSAY 'Part Number' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 20 DCSAY 'Description' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 50 DCSAY 'Qty' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 56 DCSAY 'Qty' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 62 DCSAY 'Qty' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 68 DCSAY 'U/I' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 76 DCSAY 'U/Price' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 87 DCSAY 'Tax' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
nRow++
@ nRow, 50 DCSAY 'Ord' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 56 DCSAY 'Ship' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
@ nRow, 62 DCSAY 'B/O' SAYSIZE 0 COLOR GRA_CLR_BLUE FONT '10.Helv'
nRow++
FOR i := 1 TO Len(aItems)
nRow++
@ nRow,2 DCGET aItems[i,INVOICE_ITEM_PARTNO] ;
WHEN {|| .f. } && added
@ nRow,20 DCGET aItems[i,INVOICE_ITEM_DESC] SIZE 30 ;
WHEN {|| .f. } && added
cValid := '{ || aItems[' + AS( i ) + ',INVOICE_ITEM_SUM] := ( aItems[' + AS( i ) + ',INVOICE_ITEM_QTY_ORD] * aItems[' + AS( i ) + ',INVOICE_ITEM_UPRICE] ), dc_qout(aItems) }' && added
bValid := &( cValid ) && added
wtf cValid
cGetID := ( 'GET_F' + AS( i ) ) && added
* hmmm, when I un-remark bValid, in runtime it says that aItems is not declared...
@ nRow,50 DCGET aItems[i,INVOICE_ITEM_QTY_ORD] PICT '9999' ;
; && VALID bValid ; && added
GETID cGetID && added
@ nRow,56 DCGET aItems[i,INVOICE_ITEM_QTY_SHIP] PICT '9999' ;
WHEN {|| .f. } && added
@ nRow,62 DCGET aItems[i,INVOICE_ITEM_QTY_BO] PICT '9999' ;
WHEN {|| .f. } && added
@ nRow,68 DCGET aItems[i,INVOICE_ITEM_UI] GETSIZE 7 ;
WHEN {|| .f. } && added
@ nRow,76 DCGET aItems[i,INVOICE_ITEM_UPRICE] PICT '99999.99' ;
WHEN {|| .f. } && added
@ nRow,88 DCCHECKBOX aItems[i,INVOICE_ITEM_TAXABLE] ;
WHEN {|| .f. } && added
@ nRow,94 DCGET aItems[i,INVOICE_ITEM_SUM] PICT '99999.99' ; && added
WHEN {|| .f. } && added
@ nRow,105 DCGET aItems[i,INVOICE_ITEM_HOTKEY] ; && added
WHEN {|| .f. } && added
nHotKeyK_P := aItems[i,INVOICE_ITEM_HOTKEY_P] && added
nHotKeyK_M := aItems[i,INVOICE_ITEM_HOTKEY_M] && added
wtf nHotKeyK_P, nHotKeyK_M
cHotKeyK_P := '{ || MsgBox("plus-' + AS( i ) + '") }' && added
* cHotKeyK_P := '{ || MsgBox("plus-' + 'aItems[' + AS( i ) + ',INVOICE_ITEM_SUM]' + '") }' && added
* cHotKeyK_P := '{ |a| a:= aItems[' + AS( i ) + ',INVOICE_ITEM_HOTKEY]' + ', MsgBox("plus-"' + a + ') }' && added
* cHotKeyK_P := '{ |a| a:= aItems[' + AS( i ) + ',INVOICE_ITEM_HOTKEY] }' && added
* cHotKeyK_P := '{ |a| MsgBox( Var2Char( aItems[' + AS( i ) + ',INVOICE_ITEM_HOTKEY] ) ) }' && added
wtf cHotKeyK_P
* cHotKeyK_P := '{ || MsgBox("plus-' + AS( i ) + '") }' && added
bHotKeyK_P := &( cHotKeyK_P ) && added
cHotKeyK_M := '{ || MsgBox("minus-' + AS( i ) + '") }' && added
bHotKeyK_M := &( cHotKeyK_M ) && added
wtf cHotKeyK_P, cHotKeyK_M
DCHOTKEY nHotKeyK_P ACTION bHotKeyK_P && added
DCHOTKEY nHotKeyK_M ACTION bHotKeyK_M && added
NEXT
DCSETPARENT TO
@ 25,1 DCPUSHBUTTON CAPTION 'Exit' SIZE 9,1.2 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}
@ 25,12 DCPUSHBUTTON CAPTION 'Print' SIZE 9,1.2 ;
ACTION {||aData[INVOICE_ITEMS] := aItems, PrintInvoice(aData)}
@ 25,24 DCPUSHBUTTON CAPTION 'Email Setup' SIZE 12,1.2 ;
ACTION {||EmailSetup()}
DCGETOPTIONS ;
HILITEGETS GRA_CLR_RED ;
SAYWIDTH 100 ;
SAYRIGHT ;
DISABLEDCOLOR GRA_CLR_WHITE
DCREAD GUI FIT OPTIONS GetOptions ;
TITLE 'Create and Print an Invoice' ;
TO lStatus SETAPPWINDOW ;
EVAL { |o| wtf o, GetList } && added
IF lStatus
UpdateTotals( aData, aItems )
aInvoice := aData
aInvoice[INVOICE_ITEMS] := aItems
SAVE ALL LIKE aInvoice TO INVOICE.XPF
ENDIF
RETURN nil
* ----------------
STATIC FUNCTION UpdateTotals( aData, aItems )
LOCAL i, nTaxable := 0, nNonTaxable := 0, nSalesTax := 0
FOR i := 1 TO Len(aItems)
aItems[i,INVOICE_ITEM_AMOUNT] := ;
aItems[i,INVOICE_ITEM_QTY_SHIP] * aItems[i,INVOICE_ITEM_UPRICE]
IF aItems[i,INVOICE_ITEM_TAXABLE]
nTaxable += aItems[i,INVOICE_ITEM_AMOUNT]
nSalesTax += aItems[i,INVOICE_ITEM_AMOUNT] * aData[INVOICE_TAXRATE]
ELSE
nNonTaxable += aItems[i,INVOICE_ITEM_AMOUNT]
ENDIF
NEXT
aData[INVOICE_TAXABLE] := nTaxable
aData[INVOICE_NONTAXABLE] := nNonTaxable
aData[INVOICE_SALESTAX] := nSalesTax
aData[INVOICE_TOTAL] := nTaxable + nNonTaxable + nSalesTax + ;
aData[INVOICE_FREIGHT] + aData[INVOICE_MISC]
RETURN nil
* ----------------
STATIC FUNCTION PrintInvoice( aData )
LOCAL oPrinter, nRow, nCol, nOffset, i, nLineCount, cComments, nHeight, ;
nSaveRow, aItems, cMemoLine, aAcrobatOptions
IF !Print_Choice( 'Print Invoice', 1, 'rogerdonnay@donnay-software.com', FALSE )
RETURN FALSE
ENDIF
IF !PrintOn('Invoice',@oPrinter)
RETURN FALSE
ENDIF
nRow := 2
// Print Logo
@ nRow,4,nRow+7,20 DCPRINT BITMAP aData[INVOICE_LOGO] AUTOSCALE
// Print Invoice Number Box
@ nRow,60,nRow+7,77 DCPRINT BOX FILL 3 GRAY 10
@ nRow+2,60,nRow+2,77 DCPRINT LINE
@ nRow+.6,62 DCPRINT SAY 'INVOICE' FONT '22.Arial Bold'
@ nRow+2.1,62 DCPRINT SAY aData[INVOICE_NUMBER] FONT '14.Courier New Bold'
@ nRow+4,60,nRow+4,77 DCPRINT LINE
@ nRow+5,61 DCPRINT SAY 'Date:'
@ nRow+5,67 DCPRINT SAY DtoC(aData[INVOICE_DATE]) FONT '10.Courier New'
// Print Company Heading (Name and Address)
DCPRINT FONT '12.Arial Bold'
@ nRow++,40 DCPRINT SAY Trim(aData[INVOICE_FROM_NAME]) ALIGN DCPRINT_ALIGN_HCENTER
@ nRow++,40 DCPRINT SAY Trim(aData[INVOICE_FROM_ADDR1]) ALIGN DCPRINT_ALIGN_HCENTER
IF !Empty(aData[INVOICE_FROM_ADDR2])
@ nRow++,40 DCPRINT SAY Trim(aData[INVOICE_FROM_ADDR1]) ALIGN DCPRINT_ALIGN_HCENTER
ENDIF
@ nRow++,40 DCPRINT SAY Trim(aData[INVOICE_FROM_CITY]) + ', ' + ;
Trim(aData[INVOICE_FROM_STATE]) + ' ' + ;
Trim(aData[INVOICE_FROM_ZIP]) ;
ALIGN DCPRINT_ALIGN_HCENTER
@ nRow++,40 DCPRINT SAY Trim(aData[INVOICE_FROM_COUNTRY]) ;
ALIGN DCPRINT_ALIGN_HCENTER
DCPRINT FONT '10.Arial'
@ nRow++,40 DCPRINT SAY 'Phone: ' + Trim(aData[INVOICE_FROM_PHONE]) ;
ALIGN DCPRINT_ALIGN_HCENTER
@ nRow++,40 DCPRINT SAY 'Fax: ' + Trim(aData[INVOICE_FROM_FAX]) ;
ALIGN DCPRINT_ALIGN_HCENTER
@ nRow++,40 DCPRINT SAY 'E-Mail: ' + Trim(aData[INVOICE_FROM_EMAIL]) ;
ALIGN DCPRINT_ALIGN_HCENTER
nRow += 3
// Print Bill To and Ship To boxes
@ nRow,4, nRow+10,40 DCPRINT BOX GRAY 5
@ nRow+1.5,4, nRow+1.5,40 DCPRINT LINE
@ nRow,5 DCPRINT SAY 'Bill To:' FONT '10.Arial'
@ nRow,42, nRow+10,77 DCPRINT BOX GRAY 5
@ nRow+1.5,42, nRow+1.5,77 DCPRINT LINE
@ nRow,43 DCPRINT SAY 'Ship To:' FONT '10.Arial'
nRow += 2
nCol := 5
DCPRINT FONT '12.Courier New'
nSaveRow := nRow
// Print Bill To Name and Address
IF !Empty(aData[INVOICE_BILL_CONTACT])
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_BILL_CONTACT])
ENDIF
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_BILL_NAME])
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_BILL_ADDR1])
IF !Empty(aData[INVOICE_BILL_ADDR2])
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_BILL_ADDR2])
ENDIF
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_BILL_CITY]) + ', ' + ;
Trim(aData[INVOICE_BILL_STATE]) + ' ' + ;
Trim(aData[INVOICE_BILL_ZIP])
nRow := nSaveRow
nCol := 43
// Print Ship To Name and Address
IF !Empty(aData[INVOICE_SHIP_CONTACT])
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_SHIP_CONTACT])
ENDIF
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_SHIP_NAME])
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_SHIP_ADDR1])
IF !Empty(aData[INVOICE_SHIP_ADDR2])
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_SHIP_ADDR2])
ENDIF
@ nRow++, nCol DCPRINT SAY Trim(aData[INVOICE_SHIP_CITY]) + ', ' + ;
Trim(aData[INVOICE_SHIP_STATE]) + ' ' + ;
Trim(aData[INVOICE_SHIP_ZIP])
// Print Heading Box
DCPRINT FONT '10.Arial'
nRow += 5
nCol := 16
@ nRow, 4, nRow+4,77 DCPRINT BOX
@ nRow+1.6, 4, nRow+1.6,77 DCPRINT LINE
@ nRow, nCol, nRow+4,nCol DCPRINT LINE
@ nRow, nCol - 11 DCPRINT SAY 'P.O. No'
nCol += 12
@ nRow, nCol, nRow+4,nCol DCPRINT LINE
@ nRow, nCol - 11 DCPRINT SAY 'S.O. No'
nCol += 12
@ nRow, nCol, nRow+4,nCol DCPRINT LINE
@ nRow, nCol - 11 DCPRINT SAY 'Salesman'
nCol += 12
@ nRow, nCol, nRow+4,nCol DCPRINT LINE
@ nRow, nCol - 11 DCPRINT SAY 'Terms'
nCol += 12
@ nRow, nCol, nRow+4,nCol DCPRINT LINE
@ nRow, nCol - 11 DCPRINT SAY 'Ship Via'
nCol += 12
@ nRow, nCol - 11 DCPRINT SAY 'Ship Date'
nRow += 2
nCol := 16
DCPRINT FONT '8.Arial'
@ nRow, nCol - 11 DCPRINT SAY Trim(aData[INVOICE_PO_NO])
nCol += 12
@ nRow, nCol - 11 DCPRINT SAY Trim(aData[INVOICE_SO_NO])
nCol += 12
@ nRow, nCol - 11 DCPRINT SAY Trim(aData[INVOICE_SALESMAN])
nCol += 12
@ nRow, nCol - 11 DCPRINT SAY Trim(aData[INVOICE_TERMS])
nCol += 12
@ nRow, nCol - 11 DCPRINT SAY Trim(aData[INVOICE_SHIP_VIA])
nCol += 12
@ nRow, nCol - 11 DCPRINT SAY Dtoc(aData[INVOICE_SHIP_DATE])
nRow += 4
nCol := 5
nHeight := 24
// Print Items Box
@ nRow, 4, nRow+nHeight, 77 DCPRINT BOX
@ nRow+2.6, 4, nRow+2.6, 77 DCPRINT LINE
DCPRINT FONT '10.Arial'
@ nRow, nCol DCPRINT SAY 'Part No / '
@ nRow+1, nCol DCPRINT SAY 'Description'
nCol += 29
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Qty'
@ nRow+1, nCol + 1 DCPRINT SAY 'Ord'
nCol += 6
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Qty'
@ nRow+1, nCol + 1 DCPRINT SAY 'Ship'
nCol += 6
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Qty'
@ nRow+1, nCol + 1 DCPRINT SAY 'B/O'
nCol += 6
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'U/I'
nCol += 6
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'U/Price'
nCol += 8
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Amount'
nCol += 8
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + .4 DCPRINT SAY 'Tax'
nSaveRow := nRow
nRow += 3.6
aItems := aData[INVOICE_ITEMS]
// Print Items
DCPRINT FONT '8.Arial'
FOR i := 1 TO Len(aItems)
IF Empty(aItems[i,INVOICE_ITEM_DESC])
EXIT
ENDIF
nCol := 5
nOffset := 0
IF !Empty(aItems[INVOICE_ITEM_PARTNO])
@ nRow, nCol DCPRINT SAY Trim(aItems[i,INVOICE_ITEM_PARTNO])
nOffset++
ENDIF
@ nRow+nOffset, nCol DCPRINT SAY Trim(aItems[i,INVOICE_ITEM_DESC])
nCol += 29
@ nRow, nCol + 2 DCPRINT SAY aItems[i,INVOICE_ITEM_QTY_ORD] PICT '999' FIXED
nCol += 6
@ nRow, nCol + 2 DCPRINT SAY aItems[i,INVOICE_ITEM_QTY_SHIP] PICT '999' FIXED
nCol += 6
@ nRow, nCol + 2 DCPRINT SAY aItems[i,INVOICE_ITEM_QTY_BO] PICT '999' FIXED
nCol += 6
@ nRow, nCol + 1 DCPRINT SAY Trim(aItems[i,INVOICE_ITEM_UI])
nCol += 6
@ nRow, nCol + 1 DCPRINT SAY aItems[i,INVOICE_ITEM_UPRICE] PICT '9999.99' FIXED
nCol += 8
@ nRow, nCol DCPRINT SAY aItems[i,INVOICE_ITEM_AMOUNT] PICT '99999.99' FIXED
nCol += 8
IF aItems[i,INVOICE_ITEM_TAXABLE]
@ nRow, nCol + 1 DCPRINT SAY '*'
ENDIF
nRow += 2 + nOffset
NEXT
nRow := nSaveRow + nHeight + 2
nCol := 5
nHeight := 4
nOffset := 2.2
@ nRow, 4, nRow+nHeight,77 DCPRINT BOX
@ nRow+1.8, 4, nRow+1.8,77 DCPRINT LINE
DCPRINT FONT '10.Arial'
@ nRow, nCol DCPRINT SAY 'Non-Taxable'
@ nRow+nOffset,nCol DCPRINT SAY aData[INVOICE_NONTAXABLE] PICT '99999.99'
nCol += 12
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Taxable'
@ nRow+nOffset,nCol DCPRINT SAY aData[INVOICE_TAXABLE] PICT '99999.99'
nCol += 12
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Sales Tax'
@ nRow+nOffset,nCol DCPRINT SAY aData[INVOICE_SALESTAX] PICT '99999.99'
nCol += 12
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Freight'
@ nRow+nOffset,nCol DCPRINT SAY aData[INVOICE_FREIGHT] PICT '99999.99'
nCol += 12
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Misc.'
@ nRow+nOffset,nCol DCPRINT SAY aData[INVOICE_MISC] PICT '99999.99'
nCol += 12
@ nRow, nCol, nRow+nHeight,nCol DCPRINT LINE
@ nRow, nCol + 1 DCPRINT SAY 'Invoice Total' FONT '10.Arial Bold'
@ nRow+nOffset,nCol DCPRINT SAY aData[INVOICE_TOTAL] PICT '99999.99' ;
FONT '12.Arial Bold'
nRow += 4
// Print comments
DCPRINT FONT '10.Courier New'
cComments := Alltrim(aData[INVOICE_COMMENTS])
nLineCount := MLCount(cComments)
FOR i := 1 TO nLineCount
cMemoLine := MemoLine( cComments, nil, i )
@ nRow+i,5 DCPRINT SAY cMemoLine
NEXT
PrintOff(oPrinter)
RETURN nil
* ----------------
PROC appsys
RETURN
* ----------------
Function AS( _cNumber )
RETURN AllTrim( Str( _cNumber ) )
*
In my current „hard-writed“ prg code all work like I need, but I don‘t know how do it in your version with locals variables.
TIA
Zdeno