diff --git a/src/AppMain.c b/src/AppMain.c index 97c763d..1887694 100644 --- a/src/AppMain.c +++ b/src/AppMain.c @@ -159,8 +159,8 @@ Boolean gQuantityTouched; typedef struct { Char barcode[15]; - UInt16 cases; - UInt16 units; + Char cases[4]; + Char units[4]; } RattailScanRecord; @@ -794,15 +794,21 @@ static Boolean MainFormDoCommand(UInt16 command) static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds) { Char* barcode; - Char quantity[4]; + Char* quantity; Coord x; if (col == 0) { + /* + * The barcode string is drawn normally. + */ barcode = (Char*) TblGetItemPtr(table, row, col); WinDrawChars(barcode, StrLen(barcode), bounds->topLeft.x, bounds->topLeft.y); } else { - StrIToA(quantity, TblGetItemInt(table, row, col)); + /* + * Case and unit quantities are right-justified. + */ + quantity = (Char*) TblGetItemPtr(table, row, col); x = bounds->topLeft.x + bounds->extent.x - FntCharsWidth(quantity, StrLen(quantity)); WinDrawChars(quantity, StrLen(quantity), x, bounds->topLeft.y); } @@ -965,8 +971,8 @@ static void MainFormLoadTable(TablePtr table, Boolean updateScroll) recordP = MemHandleLock(recordH); TblSetItemPtr(table, row, 0, recordP->barcode); - TblSetItemInt(table, row, 1, recordP->cases); - TblSetItemInt(table, row, 2, recordP->units); + TblSetItemPtr(table, row, 1, recordP->cases); + TblSetItemPtr(table, row, 2, recordP->units); MemHandleUnlock(recordH); DmReleaseRecord(db, recordIndex, false); @@ -1344,16 +1350,22 @@ static void StoreScanRecord() MemPtr recordP; TablePtr table; + /* + * Make sure we start off clean. This will make it easier to parse the + * record on the PC side, and is probably good practice anyhow. + */ + MemSet(&record, sizeof(RattailScanRecord), 0); + form = FrmGetFormPtr(MainForm); ctrl = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormBarcode)); StrCopy(record.barcode, FldGetTextPtr((FieldPtr) ctrl)); ctrl = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormCases)); - record.cases = StrAToI(CtlGetLabel(ctrl)); + StrCopy(record.cases, CtlGetLabel(ctrl)); ctrl = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormUnits)); - record.units = StrAToI(CtlGetLabel(ctrl)); + StrCopy(record.units, CtlGetLabel(ctrl)); db = OpenScanDatabase(); recordIndex = dmMaxRecordIndex;