The text of a manual · part 18 of 21
Symbol Palm Terminal Scanner System Software Manual, pages 145 to 152
Pages 145 to 152 of 168
The original document is the PDF (1.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Symbol SPT-1700
Page 145
Sample Scanning Application
UpdateScrollBbar(); bHandled = true; break; case sclRepeatEvent: ScrollLines(event->data.sclRepeat.newvalue - event -> data.sclRepeat.value, false); break; case keyDownEvent; { if (event->data.keyDown.chr ==pageUpChr) { PageScroll (up); bHandled = true; }else if (event->data.keyDown.chr ==pageDownChr) { PageScroll (down); bHandled = true; } break; { } //end switch return(bHandled); }
6-7
Page 146
Symbol Palm Terminal Scanner System Software Manual
/***************************************************************** * * FUNCTION: MainFormOnInit * * DESCRIPTION: This routine sets up the initial state of the main * form. * * PARAMETERS: None. * * RETURNED: Nothing. * *****************************************************************/ static void MainFormOnInit() { FormPtr pForm = FrmGetActiveForm(); if( pForm ) { // initialize the barcode type and barcode data fields SetFieldText(MainBarTypeField, "No Data", 20, false ); SetFieldText(MainScandataField, "No Data", 80, false ); FrmDrawForm( pForm ); } } /***************************************************************** * * FUNCTION: MainFormHandleMenu * * DESCRIPTION: This routine handles menu selections off of the * main form. * * PARAMETERS: None. * * RETURNED: Nothing. * *****************************************************************/ void MainFormHandleMenu( Word menuSel ) { switch( menuSel )
6-8
Page 147
Sample Scanning Application
{ // Options menu case OptionsResetDefaults: if (ScanIsPalmSymbolUnit()) { ScanCmdScanDisable(); if (ScanCmdParamDefaults () ==Status_OK) ScanCmdScanEnable (); //enable scanning } break; case OptionsAbout: OnAbout(); break; } } /***************************************************************** * * FUNCTION: OnDecoderData * * DESCRIPTION: Handles processing of events for the main form. * * PARAMETERS: None * * RETURNED: True if the event is handled, false otherwise. * *****************************************************************/ Boolean OnDecoderData() //GetSerialData() { static Char BarTypeStr[80]=" "; MESSAGE decodeDataMsg; int status; VoidHand hExtendedData; unsigned char*pExtendedData; int extendedDataType; Word numlines; if (extend) {
6-9
Page 148
Symbol Palm Terminal Scanner System Software Manual hExtendedData = MemHandleNew ( extendedDataLength); pExtendedData = (unsigned char *) MemHandleLock (hExtendedData); status = ScanGetExtendedDecodedData (extendedDataLength, &extendedDataType, pExtendedData); } else
{ status = ScanGetDecodedData ( &decodeDataMsg); extendedDataType = decodeDataMsg.type extendedDataLength = decodeDataMsg.length; hExtendedData = MemHandleNew (extendedDataLength +1) pExtendedData = (unsigned char *) MemHandleLock (hExtendedData); pExtendedData [extendedDataLength] = ‘\0’; MemMove (&pExtendedData [0], &decodeDataMsg.data [0], extendedDataLength+1);
} if (status == STATUS_OK ) // if we successfully got the decode // data from the API... FieldPTR pField; //call a function to translate barcode type into a //string, and display it ScanGetBarTypeStr (extendedDataType, BarTypeStr, 30); //in Utils.c SetFieldText (MainBarTypeField, BarTypeStr, 30, true); //Check to see if this scan was a “No Read Data” //(indicated by type of zero) if (extendedDataType ==0) { SetFieldText (MainScandataField, “No Scan”, 30, true); } else { // Place the barcode data into the field and //display /*Set up data display field to display the memory*/
6-10
Page 149
Sample Scanning Application pField =(FieldPtr)GetObjectPtr(MainScandataField); pField->attr.editable =true; FldDelete (pField, 0, FldGetTextLength (pField)); //clear out old data if (extendedDataLength -> FldGetMaxChars (pField)) FldSetMaxChars (pField, extendedDataLength); FldEraseField (pField);//hide field so we don’t see the //data scroll in FldInsert(pField, (char*) (&pExtendedData [0], extendedDataLength); //move to top of scroll bar numlines = FldCalcFieldHeight ((char*)&pExtendedData [0], SCANDATA_WIDTH); ScrollLines (-numlines, false);//scroll to top of data FldDrawField(pField); // show field pField->attr.editable = false; } } UpdateScrollbar(); MemHandleUnlock (hExtendedData); MemHandleFree (hExtendedData); return(0); } MainFormHandleEvent handles five specific events. Most are standard Palm events that are probably already familiar to you. However, two are events that scan-aware applications will need to handle. !
scanDecodeEvent is a special event issued by the Scan Manager software to your application. It signals to your code that a scan (either successful or unsuccessful) has been completed. In response to the scanDecodeEvent, you can call the ScanGetDecodedData Scan Manager function, which gives you the results from the most recent scan. This is illustrated in the OnDecoderData function shown previously.
6-11
Page 150
Symbol Palm Terminal Scanner System Software Manual
!
scanBatteryErrorEvent is another special event issued by Scan Manager to your application. You receive this event whenever a scan operation fails because of low battery levels. When this condition occurs, the scanner is disabled until the batteries are replaced or recharged. Because of this, and because this condition occurs sooner than the normal low-battery warning of a Palm organizer, it is important that you execute some code to alert end-users. The Sscan application does this by issuing an alert.
!
frmOpenEvent is a standard event that most Palm organizer developers are familiar with. Sscan calls MainFormOnInit to initialize and draw the main form.
!
menuEvent is another standard Palm event. The menuEvent code in Sscan allows you to issue a decoder command to reset all of the decoder parameters to their defaults. It also allows you to display an About form with all of the version information for your SPT scanner software.
!
ctlSelectEvent is an event received by the application in response to the user pushing a button. In Sscan, it is in response to the “Scan” button on the main form. Upon receiving this event, a scan is initiated by calling the ScanCmdStartDecode Scan Manager API function.
The StopApplication Function The StopApplication function is called at the conclusion of PilotMain. This function first uses ScanIsPalmSymbolUnit to make sure the application is running on an SPT device. We recommend this check only if your software might be running on both unmodified Palm III devices and SPT devices. If Sscan is running on an SPT device, we call ScanCmdScanDisable to disable scanning. This is not required, merely suggested. Finally, you must call the ScanCloseDecoder function before exiting your program. This function powers down the decoder and closes the Scan Manager shared library. Failure to call ScanCloseDecoder can cause unpredictable system problems.
6-12
Page 151
Sample Scanning Application
/***************************************************************** * * FUNCTION: StopApplication * * DESCRIPTION: This routine does any cleanup required, including * shutting down the decoder and Scan Manager shared * library. * * PARAMETERS: None. * * RETURNED: Nothing. * *****************************************************************/ static void StopApplication(void) { if (ScanIsPalmSymbolUnit()) { // Disable scanner and close Scan Manager library ScanCmdScanDisable(); ScanCloseDecoder(); } }
6-13
Page 152
Symbol Palm Terminal Scanner System Software Manual
6-14