[[TOC]] = CTktFlds = CTktFlds is a C++ class that is a wrapper around struct tktfld_struct to simplify ticket programming. == Constructor == {{{ CTktFlds(void); }}} ==== Parameters ==== Constructor does not accept any parameters ==== Examples ==== {{{ CTktFlds flds; }}} This contructs the object. == Member Functions == === Clear === Clears all references or a specified item. {{{ void Clear(void); void Clear(int nFld); }}} ==== Parameters ==== * nFld - Ticket item to clear Version with no parameters clears all fields ==== Return Value ==== Function does not return a result. ==== Remarks ==== ==== Examples ==== {{{ CTktFlds flds; flds.Set(TKT_FLD_TIME, strTime); flds.Set(TKT_FLD_GROSS, strGross); PrintTkt(TKT_STD, flds); }}} {{{ CTktFlds flds; flds.Set(TKT_FLD_TIME, strTime); flds.Set(TKT_FLD_GROSS, strGross); flds.PrintTkt(TKT_STD); // Clear the entire flds object to start over flds.Clear(); flds.Set(TKT_FLD_TIME, strTime); flds.Set(TKT_FLD_NET, strNet); flds.PrintTkt(TKT_ALT); }}} {{{ CTktFlds flds; flds.Set(TKT_FLD_TIME, strTime); flds.Set(TKT_FLD_GROSS, strGross); flds.PrintTkt(TKT_STD); // Clear the gross weight reference so it will not print on the alternate ticket, time will still print flds.Clear(TKT_FLD_GROSS); flds.Set(TKT_FLD_NET, strNet); flds.PrintTkt(TKT_ALT); }}} === Set === Sets a reference {{{ void Set(int nFld, string& str); void Set(int nFld, char* psz); void Set(int nFld, const char* psz); }}} ==== Parameters ==== * nFld - Field to set * str - String variable * psz - pointer to character array ==== Retrun Value ==== Function does not return any result. ==== Remarks ==== The TKT_FLD_xxx definitions relate to the ticket field position information provided in the "Configuration" program. Refer to the chart below. ||ID||Typical use||Code Character|| ||TKT_FLD_GROSS||Gross weight||1|| ||TKT_FLD_TARE||Tare weight||2|| ||TKT_FLD_NET||Net weight||3|| ||TKT_FLD_TIME||Time||4|| ||TKT_FLD_DATE||Date||5|| ||TKT_FLD_ID||ID||6|| ||TKT_FLD_CN||Consecutive number||7|| ||TKT_FLD_UNITS||Weight units||8|| ||TKT_FLD_DSP_WT||Display weight||9|| ||TKT_FLD_PC_CNT||Piece count||A|| ||TKT_FLD_TOT_CNT||Total count||B|| ||TKT_FLD_ID1||ID1||C|| ||TKT_FLD_ID2||ID2||D|| ||TKT_FLD_ID3||ID3||E|| ||TKT_FLD_G_ACCUM||Gross weight accumulator||F|| ||TKT_FLD_N_ACCUM||Net weight accumulator||G|| ||TKT_FLD_PRMPT1||Prompt 1||H|| ||TKT_FLD_PRMPT2||Prompt 2||I|| ||TKT_FLD_PRMPT3||Prompt 3||J|| ||TKT_FLD_REF1||Reference 1||K|| ||TKT_FLD_REF2||Reference 2||L|| ||TKT_FLD_REF3||Reference 3||M|| ||TKT_FLD_CNV_NET||Converted net weight||Z|| The following are not standard nControl fields: ||ID||Typical use||Code Character|| ||TKT_FLD_CNV_UNITS||Converted weight units||0 (Zero)|| ||TKT_FLD_CNV_DSP_WT||Converted display weight||U|| ||TKT_FLD_CNV_G_ACCUM||Converted gross accumulator||V|| ||TKT_FLD_CNV_N_ACCUM||Converted net accumulator||W|| ||TKT_FLD_CNV_GROSS||Converted gross weight||X|| ||TKT_FLD_CNV_TARE||Converted tare weight||Y|| ||TKT_FLD_IN_TIME||Time In - First pass time||N|| ||TKT_FLD_IN_DATE||Date In - First pass date||O|| ||TKT_FLD_ID4||ID4||P|| ||TKT_FLD_PRMPT4||Prompt 4||Q|| ||TKT_FLD_CUSTOM||Custom field||R|| The Set function does not copy the provided data, but only creates a reference to it. The provided data must remain in scope until after the PrintTkt function is performed (Otherwise garbled data may appear in the output or the indicator may crash). ==== Example ==== {{{ string strTime = GetTimeStr(1); // Include seconds string strGross = FormatGrossWt(1); CTktFlds flds; flds.Set(TKT_FLD_TIME, strTime); flds.Set(TKT_FLD_GROSS, strGross); flds.PrintTkt(TKT_STD); }}} === !SetEvent === Sets an event to allow the application to do some processing during printing {{{ void SetEvent(void* userData, TKT_EVENT func); }}} ==== Parameters ==== * userData - Pointer to anything that may be useful to the event function * func - Event function ==== Retrun Value ==== Function does not return any result. ==== Remarks ==== The event function receives four parameters. tkt is the ticket format TKT_STD, TKT_ALT, TKT_FPASS, TKT_LOG, TKT_SPEC1, ... TKT_SPEC6. p is a pointer to the struct tktfld_struct, file is the FILE* pointer for the output, code is the point during printing TKT_EVENT_BEFORE_BEGIN_PRINT (before begin print codes are printed) TKT_EVENT_AFTER_BEGIN_PRINT (after the begin print codes are printed but before any ticket text is printed) TKT_EVENT_BEFORE_END_PRINT (after ticket text is printed but before ending print codes are printed) TKT_EVENT_AFTER_END_PRINT (after end print codes are printed). ==== Example ==== {{{ struct tran_info_struct { int tktNum; // ... other data } tran; TKT_EVENT(PrintBarCode) { if(tkt == TKT_FPASS && code == TKT_EVENT_BEFORE_END_PRINT) { // Print bar code of the ticket number on P600 printer struct tran_info_struct* pTran = (tran_info_struct*)p->userStruct; if(pTran != NULL) { fprintf(file, "%cb428%c%07d%c", 0x1B, 0x40, pTran->tktNum, 0x1E); } } return 0; } void AppPrint(void) { string strTime = GetTimeStr(1); // Include seconds string strTare = FormatTareWt(1); tran.tktNum++; CTktFlds flds; flds.Set(TKT_FLD_TIME, strTime); flds.Set(TKT_FLD_TARE, strTare); flds.SetEvent(&tran, TktEventPrintBarCode); flds.PrintTkt(TKT_FPASS); } }}} === PrintTkt === Print the ticket {{{ void PrintTkt(int nFmt, int verbose = 0); void PrintTkt(int nFmt, CComm* pComm, CCommConnection* pConnection, int verbose = 0); }}} ==== Parameters ==== * nFmt - Specify the ticket format to print: TKT_STD, TKT_ALT, TKT_FPASS, TKT_LOG, TKT_SPEC1 - TKT_SPEC6 * verbose - 1 to output detailed messages * pComm - Specify a CComm instance to output to * pConnection - If pComm is used a particular connection instance may be specified. ==== Return Value ==== Function does not return a result. ==== Remarks ==== ==== Examples ====