The following is a simple example DP4 C application that uses some of the PODs from the DP4 Till. It initialises the DP4 Till, sends output to the journal printer, requests the status of the Till drawer and finally sets input to the scanner. Further information is given in the code comments:
This program is an example only - it would be very bad practice to use hard coded messages in a real program.
/* DP4 C LIBMAKE definitions :
#db time2
#c
#end
*/
#include "dp4.h"
#include "tillapp.h"
#include "devices.h" /* Device definition header file from DFSETUP */
/* Input device mask values */
#define INP_KEYBOARD 1
#define INP_SCANNER 2
/* Map numbers (map definitions not shown )*/
#define M_TEXT_REQUEST 6
#define M_TEXT_PRINT 7
#define M_DRAWER_STATUS 8
#define M_WARNING 10
/* prototypes */
void text_out(char *);
void request_user_text(char *);
/**/
void process()
{
char ptext[80];
char status_str[20];
char pause_char;
pr_err_mode = 2; /* Ignore errors and continue */
map_load("TILLAPP");
/* Initialise device */
dvc_choose(PRINTER+NO_SELECT, TILL_INIT, "", "");
/* Print string to journal */
dvc_set_subdevice(JOURNAL_PRINTER);
if (print_error)
{
map_draw(M_WARNING, ERRORMAP);
show_c(M_WARNING, 1, "Error initialising journal printer");
}
else
text_out("Hallo journal");
/* Check status of drawer */
dvc_set_subdevice(TILL_DRAWER);
dvc_get_status(status_str);
/* Display status */
map_draw(M_DRAWER_STATUS, DATAMAP);
if (status_str[0] == '1')
show_c(M_DRAWER_STATUS, 1, "Open");
else if (status_str[0] == '0')
show_c(M_DRAWER_STATUS, 1, "Closed");
askf_c(M_DRAWER_STATUS, 2, &pause_char);
map_clear(M_DRAWER_STATUS);
/* Get some scanner input */
dvc_set_inp_mask(INP_SCANNER+INP_KEYBOARD);
request_user_text(ptext);
text_out(ptext);
}
/**/
void request_user_text(char *text)
{
/* Get text from user */
map_draw(M_TEXT_REQUEST, DATAMAP);
askf_c(M_TEXT_REQUEST, 1, text);
map_clear(M_TEXT_REQUEST);
}
/**/
void text_out(char *text)
{
/* Output text - used to output to current POD */
form(M_TEXT_PRINT);
prn_c(M_TEXT_PRINT, 1, text);
prn_print(FALSE);
if (print_error)
{
map_draw(M_WARNING, ERRORMAP);
show_c(M_WARNING, 1, "Error printing");
}
}
|