{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare function security_check, set_printer, get_printer, msg, fieldcount, Printer_Select\r\ndeclare subroutine security_err_msg\r\n$insert security_rights_equ\r\n$insert oiprint_equates\r\n$insert msg_equates\r\nequ OrderNo$  to 1\r\nequ CustNo$   to 2\r\nequ CustName$ to 3\r\nequ Division$ to 4\r\nequ Po$       to 5\r\nequ Contact$  to 6\r\nif security_check( 'Order', Print$ ) then\r\n   * pull off variables\r\n   TextFields = 'ORDER_NO/CUST_NO/CUST_NAME/DIVISION/PO/CONTACT_NAME'\r\n   swap '/' with @rm:@window:'.' in TextFields\r\n   TextFields = @window:'.':TextFields\r\n   TextFields = get_property( TextFields, 'TEXT' )\r\n   convert @rm to @fm in TextFields\r\n   OrderNo  = TextFields<OrderNo$>\r\n   CustNo   = TextFields<CustNo$>\r\n   CustName = TextFields<CustName$>\r\n   Division = TextFields<Division$>\r\n   Po       = TextFields<Po$>\r\n   Contact  = TextFields<Contact$>\r\n   OrderDetail = .order_detail->array\r\n   \r\n   PrintPath\t= Printer_Select('',1)\t\t;* Select default printer\r\n\r\n\tIF PrintPath = '' THEN\r\n\t\tDef = \"\"\r\n\t\tDef<MTYPE$> = \"TA3\"\r\n\t\tDef<MTEXT$> = 'Destination Printer not Selected..'\r\n\t\tDef<MCAPTION$> = ''\r\n\t\tDef<MICON$> = '*'\r\n\t\tMsg(@WINDOW, Def, '')\r\n\t\tRETURN 0\r\n\tEND\r\n\r\n\tFileName = ''\r\n\tTitle = ''\r\n\tPageInfo = '':@fm:'':@fm:0:@fm:''\r\n\tPageSetup = 0\r\n\tPrintSetup = ''\r\n\r\n\tstat = Set_Printer(\"INIT\",FileName,Title,PageInfo,PageSetup,PrintSetup,PrintPath)\r\n\r\n   *Stat = set_printer( 'INIT', '', '', '':@fm:'':@fm:0:@fm:'', 0,)\r\n   gosub CheckErr\r\n   Font = \"Courier New,12,L,1\"\r\n   convert ',' to @fm in Font\r\n   Hf = Font\r\n   Stat = set_printer( 'FONT', Font )\r\n   gosub CheckErr\r\n   gosub PrintToF\r\n   Font<2> = 9\r\n   Font<4> = 0\r\n   Void = set_printer( 'FONT', Font )\r\n   gosub CheckErr\r\n   Void = set_printer( 'TEXT', '' )\r\n   TableColSize = '>+360':@vm:'>+720':@vm:'>+634':@vm:'>+720':@vm:'>+806':@vm:'<+806':@vm:'>+634':@vm:'<+806':@vm:'<+806':@vm:'>+907':@vm:'>+907':@vm:'>+634':@vm:'>+1080':@vm:'>+1200'\r\n   Table = ''\r\n   Table<1> = 'L#~Quote~PSN~Schedule~WO~Part Num~WI#~Sub Part Num~Lot Num~Setup Chg~SRP Chg~Qty~Price~Amount'\r\n   Rcnt = fieldcount( OrderDetail<1>, @vm )\r\n   for i = 1 to Rcnt\r\n       Table<-1> = i:'~':OrderDetail<1,i>:'~':OrderDetail<2,i>:'~':OrderDetail<3,i>:'~':OrderDetail<4,i>:'~':OrderDetail<5,i>:'~':OrderDetail<6,i>:'~':OrderDetail<7,i>:'~':OrderDetail<8,i>:'~':OrderDetail<9,i>:'~':OrderDetail<10,i>:'~':OrderDetail<11,i>:'~':OrderDetail<12,i>:'~':OrderDetail<13,i>\r\n   next i\r\n   convert '~' to @vm in Table\r\n   x = Set_Printer(\"ADDTABLE\", TableColSize, '', Table, '', '', 1, TB_ALL)\r\n   *TOTALS\r\n   Table = ''\r\n   Table<1> = '~~~~~~~~~~~'\r\n   convert '~' to @vm in Table\r\n   Table<1,11> = 'Totals'\r\n   Table<1,12> = .qty_tot->array<1,1>\r\n   Table<1,14> = .order_tot->array<1,1>\r\n   x = Set_Printer(\"ADDTABLE\", TableColSize, '', Table, '', '', 1, TB_NONE)\r\n   *\r\n   TableColSize = '<+10080'\r\n   Void = set_printer( 'TEXT', '' )\r\n   OrdNotes = .order_notes->text\r\n   if OrdNotes then\r\n       x = set_printer( 'ADDTABLE', TableColSize, '', OrdNotes, '', '', 1, TB_NONE )\r\n   end\r\n   stat = set_printer( 'TERM' )       \r\n   gosub CheckErr   \r\nend else\r\n   security_err_msg( 'ORDER', Print$ )\r\nend\r\nRETURN 0\r\n*===========================================================================*\r\nPrintTof:\r\n   LineOut = ''\r\n   LineOut = fmt( 'Order No: ':OrderNo, 'L#25' ):'Entry Date: ':.entry_date->text\r\n   Void = set_printer( 'TEXT', LineOut )\r\n   LineOut = fmt( 'Cust No: ':CustNo, 'L#14' ):'  '\r\n   LineOut:= fmt( 'Name: ':CustName, 'L#35' ):'  '\r\n   LineOut:= 'Division: ':Division\r\n   Void = set_printer( 'TEXT', LineOut )\r\n   LineOut = fmt( 'Contact: ':Contact, 'L#29' ):'  '\r\n   LineOut:= fmt( 'PO#: ':Po, 'L#25' ):'  '\r\n   Void = set_printer( 'TEXT', LineOut )\r\nreturn \r\n\r\n*===========================================================================*\r\nCheckErr:\r\n    if stat < 0 then\r\n        goto FatalExit\r\n    end\r\nreturn \r\n\r\n*===========================================================================*\r\nFatalExit:\r\n    Void = msg( '', Stat )\r\n    Stat = set_printer( 'TERM' )\r\nreturn \r\n\r\n*===========================================================================*\r\n"
        }
    }
}