RFBarcode Samples

Using both Visual Basic and Visual C++ sample code, the following set of applications will demonstrate the use of the RFBarcode object and its methods. Both applications will save two barcode configurations to the RF device, limit the barcodes you may scan based upon the barcode configurations, then return the RF device to its original state when finished.

Visual Basic Sample

' RFBarcode Object Demo Application
'
' Import a sleep function from the kernel32 dll
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
' Declare an RFIO object for use throughout the
' demo application.
Public rfConsole As New RFIO
' Declare an RFBarcode object for use throughout the
' demo application.
Public rfBCode As New RFBARCODE
' strBuffer is a temp storage buffer
Dim strBuffer As String
' bStored is the main screen's storage flag
Dim bStored As Boolean

Public Sub Main()
' This application demonstrates the use of the various
' RFBarcode methods. It assumes a display area of 20x8.
' In practice, one should use an RFTerminal
' object to format output to fit the current device.
' The following lines clear the display and output the
' app title in reverse video.
    rfConsole.RFPrint 0, 0, "   Welcome To The   ", _
              WLCLEAR + WLREVERSE
    rfConsole.RFPrint 0, 1, "   RFBarcode Demo   ", WLREVERSE
    rfConsole.RFPrint 0, 3, "Hit a key to proceed", WLNORMAL
' Hide the cursor for a cleaner display
    rfConsole.RFPrint 0, 9, "", WLNORMAL
'
' Flush the output buffer and await a keystroke/scan
    If rfConsole.GetEvent() = "" Then
        GoTo ExitApp
    End If  ' If rfConsole.GetEvent() = ""
 
' When writing RF applications, the ability to determine
' which barcodes may be scanned is of great importance.
' If the application can limit its input, there
' is less chance of incorrect data corrupting your database.
' For demonstration purposes, we will limit our input to two
' symbologies: CODE_39, which will represent a bin location,
' & UPC_A, which will represent an item.
    rfBCode.AddBarcode CODE_39, False, DECODEON, 0, 0    ' Scan any CODE_39 barcode
    rfBCode.AddBarcode UPC_A, False, DECODEON, 12, 12    ' Scan UPC_A barcode of 12 length
 
' Store the current barcode configuration on the RF device. We will
' disable all other barcode types to prevent misscans.
    If rfBCode.StoreBarcode("BCDemo", BCDISABLED) = False Then
        rfConsole.RFPrint 0, 2, "StoreBarcode Failed!", _
                  WLCLEAR + WLREVERSE
        rfConsole.GetEvent
        GoTo ExitApp
    End If   ' If rfBCode.StoreBarcode("BCDemo", BCDISABLED) = False
 
    bStored = False
    While True
        If bStored = False Then
            rfConsole.RFPrint 0, 0, " Pseudo–Cycle Count ", _
                      WLCLEAR + WLREVERSE
            rfConsole.RFPrint 0, 2, "Input Bin/Item : ", WLNORMAL
            rfConsole.RFPrint 0, 7, "  CLR To Exit Demo  ", _
                      WLREVERSE + WLFLUSHOUTPUT
            bStored = rfConsole.PushScreen("PCCMain")
        Else: rfConsole.RestoreScreen "PCCMain"
        End If  ' If bStored = False
 
        strBuffer = rfConsole.RFInput("", 20, 0, 3, "BCDemo", _
                              NORMALKEYS, _
                              WLBACKLIGHT + WLDISABLE_KEY)
        If rfConsole.RFGetLastError() <> WLNOERROR Then
            GoTo ExitApp
        End If  ' If rfConsole.RFGetLastError() <> WLNOERROR

        If rfConsole.LastInputType() = WLCOMMANDTYPE And _
                                       Asc(strBuffer) = 27 Then
            GoTo ExitApp
        Else
            If rfConsole.LastBarcodeType() = CODE_39 Then
            ' In a real cycle count application, you would be
            ' validating the new bin location for
            ' the item counts.
                rfConsole.RFPrint 0, 2, "Bin Number Scanned", _
                          WLCLREOLN
                rfConsole.RFPrint 0, 3, strBuffer, WLCLREOLN
            ElseIf rfConsole.LastBarcodeType() = UPC_A Then


            ' Here you would request an item count or add one
            ' to the database record for the item
            ' scanned.
                rfConsole.RFPrint 0, 2, "Item Number Scanned", _
                          WLCLREOLN
                rfConsole.RFPrint 0, 3, strBuffer, WLCLREOLN
            End If   ' If rfConsole.LastBarcodeType() = CODE_39
 
            rfConsole.RFPrint 0, 7, "Hit a key to proceed", WLNORMAL
            ' Hide the cursor for a cleaner display
            rfConsole.RFPrint 0, 9, "", WLNORMAL
 
            ' Flush the output buffer and await a keystroke/scan
            If rfConsole.GetEvent() = "" Then
                GoTo ExitApp
            End If  ' If rfConsole.GetEvent() = ""
    End If  ' If rfConsole.LastInputType() = WLCOMMANDTYPE
 
        Wend    ' While True
 
' Anytime an application changes the configuration of an RF device,
' it should return it to its original values during cleanup
    rfBCode.DeleteBarcodeFile "BCDemo"
 
EitApp:
End Sub

Visual C++ Sample

/////////////////////////////////////////////////////////
//     Place RF application's main code here
IRFIO            rfConsole;          // Declare an RFIO interface
                                     // object
IRFBarcode       rfBCode;            // Declare an RFBarcode
                                     // interface object
Cstring          csBuffer;           // Storage buffer for data
                                     // strings
Short            nTmp;               // Temporary short variable
BOOL             bDone = FALSE;      // Loop Control Variable
BOOL             bStored = FALSE;    // Main screen stored flag
    // Create an RFIO object in the automated server for our use
    if (rfConsole.CreateDispatch ("WAVELINKOLE.RFIO") == FALSE) ¿
         return FALSE;
    // Create an RFBarcode object in the automated server
    // for our use
    if (rfBCode.CreateDispatch ("WAVELINKOLE.RFBARCODE") == FALSE) {
    // Release the RFIO object
    rfConsole.ReleaseDispatch ();
         return FALSE;
    }    // if (rfBCode.CreateDispatch ("WAVELINKOLE.RFBARCODE") ==
         // FALSE)
  
    // This application demonstrates the use of the various
    // RFBarcode methods.
    // It assumes a display area of 20x8. In practice, one should
    // use an RFTerminal object to format output to fit the current
    // device.
    // The following lines clear the display and output the
    // app title in reverse video.
    rfConsole.RFPrint (0,0, "   Welcome To The   ", ¿
              WLCLEAR | WLREVERSE);
    rfConsole.RFPrint (0, 1, "   RFBarcode Demo   ", WLREVERSE);
    rfConsole.RFPrint (0, 3, "Hit a key to proceed", WLNORMAL);
    // Hide the cursor for a cleaner display
    rfConsole.RFPrint (0, 9, "", WLNORMAL);
  
    // Flush the output buffer and await a keystroke/scan
    if ((rfConsole.GetEvent ()).IsEmpty () == TRUE) {
        // Release the RFIO & RFBarcode objects
        rfConsole.ReleaseDispatch ();
        rfBCode.ReleaseDispatch ();
        return FALSE;
    } // if ((rfConsole.GetEvent ()).IsEmpty () == TRUE)
  
    // When writing RF applications, the ability to determine which
    // barcodes may be scanned is of great importance. If the
    // application can limit its input, there is less chance of
    // incorrect data corrupting your database. 
    // For demonstration purposes, we will limit our input to two
    // symbologies: 
    // CODE_39, which will represent a bin location, & UPC_A,
    // which will represent an item.
    rfBCode.AddBarcode (CODE_39, FALSE, DECODEON, 0, 0); // Scan
                                                 // any CODE_39
                                                 // barcode
    rfBCode.AddBarcode (UPC_A, FALSE, DECODEON, 12, 12); // Scan
                                                 // UPC_A barcode
                                                 // of 12 length
  
    // Store the current barcode configuration on the RF device.
    // We will disable all other barcode types to prevent misscans.
    if (rfBCode.StoreBarcode ("BCDemo", BCDISABLED) == FALSE) {
        rfConsole.RFPrint (0, 2, "StoreBarcode Failed!", ¿
                  WLCLEAR | WLREVERSE);
        rfConsole.GetEvent ();
        // Release the RFIO & RFBarcode objects
        rfConsole.ReleaseDispatch ();
        rfBCode.ReleaseDispatch ();
        return FALSE;
    }   // if (rfBCode.StoreBarcode ("BCDemo", BCDISABLED) == FALSE)
// NOTE : It is a safer practice to use a const string for the
// barcode filename to prevent typos (ex. const char* const BCNAME
// = "BCDemo";).
 
    while (bDone == FALSE) {
        if (bStored == FALSE) {
            rfConsole.RFPrint (0, 0, " Pseudo-Cycle Count ", ¿
                      WLCLEAR | WLREVERSE);
            rfConsole.RFPrint (0, 2, "Input Bin/Item : ", WLNORMAL);
            rfConsole.RFPrint (0, 7, "  CLR To Exit Demo  ", ¿
                      WLREVERSE | WLFLUSHOUTPUT);
            bStored = rfConsole.PushScreen ("PCCMain");
        }     // if (bStored == FALSE)
        else rfConsole.RestoreScreen ("PCCMain");
 
        csBuffer = rfConsole.RFInput (NULL, 20, 0, 3, "BCDemo", ¿
                   NORMALKEYS,WLBACKLIGHT | WLDISABLE_KEY);
 
        if (rfConsole.LastInputType () == WLCOMMANDTYPE && 
            csBuffer [0] == char(27))
            bDone = TRUE;
        else {
            if (rfConsole.LastBarcodeType () == CODE_39) {
            // In a real cycle count application, you would be
            // validating the new location for the item counts.
                   rfConsole.RFPrint (0, 2, "Bin Number Scanned", ¿
                             WLCLREOLN);
                   rfConsole.RFPrint (0, 3, csBuffer, WLCLREOLN);
            } // if (rfConsole.LastBarcodeType () == CODE_39)
            else if (rfConsole.LastBarcodeType () == UPC_A) {
            // Here you would request an item count or add one
            // to the database record for the item scanned.
                    rfConsole.RFPrint (0, 2,  ¿
                              "Item Number Scanned", WLCLREOLN);
                   rfConsole.RFPrint (0, 3, csBuffer, WLCLREOLN);
            }
            // else if (rfConsole.LastBarcodeType () == UPC_A)
 
            rfConsole.RFPrint (0, 7, "Hit a key to proceed", ¿
                      WLNORMAL);
            // Hide the cursor for a cleaner display
            rfConsole.RFPrint (0, 9, "", WLNORMAL);
            // Flush the output buffer and await a keystroke/scan
            if ((rfConsole.GetEvent ()).IsEmpty () == TRUE) {
                   // Release the RFIO & RFBarcode objects
                   rfConsole.ReleaseDispatch ();
                   rfBCode.ReleaseDispatch ();
                   return FALSE;
            }
            // if ((rfConsole.GetEvent ()).IsEmpty () == TRUE)
 
        } // else 
 
    } // while (bDone == FALSE)
 
    // Anytime an application changes the configuration of an
    // RF device, it should return it to its original values
    // during cleanup
    rfBCode.DeleteBarcodeFile ("BCDemo");
 
    // Release the RFIO & RFBarcode objects
    rfConsole.ReleaseDispatch ();
    rfBCode.ReleaseDispatch ();

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal