| | 154 | === SetEvent === |
| | 155 | Sets an event to allow the application to do some processing during printing |
| | 156 | {{{ |
| | 157 | void SetEvent(void* userData, TKT_EVENT func); |
| | 158 | }}} |
| | 159 | |
| | 160 | ==== Parameters ==== |
| | 161 | |
| | 162 | * userData - Pointer to anything that may be useful to the event function |
| | 163 | * func - Event function |
| | 164 | |
| | 165 | ==== Retrun Value ==== |
| | 166 | |
| | 167 | Function does not return any result. |
| | 168 | |
| | 169 | ==== Remarks ==== |
| | 170 | |
| | 171 | 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). |
| | 172 | |
| | 173 | |
| | 174 | ==== Example ==== |
| | 175 | |
| | 176 | {{{ |
| | 177 | |
| | 178 | struct tran_info_struct |
| | 179 | { |
| | 180 | int tktNum; |
| | 181 | // ... other data |
| | 182 | } tran; |
| | 183 | |
| | 184 | TKT_EVENT(PrintBarCode) |
| | 185 | { |
| | 186 | if(tkt == TKT_FPASS && code == TKT_EVENT_BEFORE_END_PRINT) |
| | 187 | { |
| | 188 | // Print bar code of the ticket number on P600 printer |
| | 189 | struct tran_info_struct* pTran = (tran_info_struct*)p->userStruct; |
| | 190 | if(pTran != NULL) |
| | 191 | { |
| | 192 | fprintf(file, "%cb428%c%07d%c", 0x1B, 0x40, pTran->tktNum, 0x1E); |
| | 193 | } |
| | 194 | } |
| | 195 | return 0; |
| | 196 | } |
| | 197 | |
| | 198 | |
| | 199 | void AppPrint(void) |
| | 200 | { |
| | 201 | string strTime = GetTimeStr(1); // Include seconds |
| | 202 | string strGross = FormatGrossWt(1); |
| | 203 | |
| | 204 | tran.tktNum++; |
| | 205 | |
| | 206 | CTktFlds flds; |
| | 207 | flds.Set(TKT_FLD_TIME, strTime); |
| | 208 | flds.Set(TKT_FLD_GROSS, strGross); |
| | 209 | |
| | 210 | flds.SetEvent(&tran, TktEventPrintBarCode); |
| | 211 | |
| | 212 | flds.PrintTkt(TKT_STD); |
| | 213 | } |
| | 214 | }}} |