RFIO Samples

Using both Visual Basic and Visual C++ sample code, the following set of applications will demonstrate the implementation and capabilities of the RFIO object and its methods.

VB Example

' RFFile 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 RFFile object for use throughout the
' demo application.
Public rfFil As New rfFile
' strBuffer is a temp storage buffer
Dim strBuffer As String
' nTmp is a temp/ storage buffer for integers
Dim nTmp As Integer
 
Dim nLcv As Integer
Dim csBuffer As String
 
Public Sub Main()
' This application demonstrates the use of the various RFFile
' 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, " RFFile Method 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() = ""
 
' The WaveLink RFFile object provides an easy way for applications
' to store, retrieve, list, and delete files from the RF device.
' Sometimes it is desirable to determine if a particular file
' resides on the RF device. The use of RFListFiles is the
' quickest and easiest method to do this.
    If rfFile.RFListFiles("*.*") < 0 Then ' We're listing all files
        strBuffer = "List Error : " + rfFile.RFGetLastError()
        rfConsole.RFPrint 0, 2, strBuffer, WLCLEAR + WLFLUSHOUTPUT
        Call Sleep(2000)
        GoTo ExitApp
    End If  ' If rfFile.RFListFiles("*.*") < 0
' To find a particular file, pass the file name as the parameter to
' RFListFiles :
'      nFound = rfFile.RFListFiles ("Target.dat")
' Since we just wish to list the files on the current RF device,
' we used the wildcard notation ("*.*").
 
    nTmp = rfFile.RFFileCount()
' It would have been quicker to use the return value from RFListFile
' instead of an additional function call, but RFFileCount was used
' for demonstration purposes.
    For nLcv = 0 To nTmp
        If (nLcv Mod 7) = 0 Then
            If nLcv Then
                rfConsole.GetEvent
            End If  ' If nLcv
            rfConsole.RFPrint 0, 0, "  RF Device Files:  ", _
                      WLCLEAR + WLREVERSE
        End If   ' If (nLcv Mod 7) = 0
        rfConsole.RFPrint 0, nLcv + 1, rfFile.RFFileName(nLcv), _
                  WLNORMAL
    Next nLcv   ' For nLcv = 0 To nTmp
    rfConsole.GetEvent
 
' When it is necessary to store data files on the RF device, the
' RFFile object provides methods to store, retrieve,
' and delete them.
    rfConsole.RFPrint 0, 2, "Storing data file...", _
              WLCLEAR + WLFLUSHOUTPUT
    strBuffer = "A string representing data to be stored on an _
                RF device!"
    If rfFile.RFStoreFile("FLDemo.Dat", csBuffer) = False Then
        strBuffer = "Store Error : " + rfFile.RFGetLastError()
        rfConsole.RFPrint 0, 2, strBuffer, WLCLEAR + WLFLUSHOUTPUT
        Call Sleep(2000)
        GoTo ExitApp
    End If   ' If rfFile.RFStoreFile("FLDemo.Dat", csBuffer) = False
 
    rfConsole.RFPrint 0, 3, "Getting data file...", _
              WLNORMAL + WLFLUSHOUTPUT
    strBuffer = rfFile.RFGetFile("FLDemo.Dat")
    If rfFile.RFGetLastError() <> WLNOERROR Then
        strBuffer = "Get Error : " + rfFile.RFGetLastError()
        rfConsole.RFPrint 0, 2, csBuffer, WLCLEAR + WLFLUSHOUTPUT
        Call Sleep(2000)
        GoTo ExitApp
    End If  ' If rfFile.RFGetLastError() <> WLNOERROR

    If strBuffer = "A string representing data to be stored on _
                   an RF device!" Then
        rfConsole.RFPrint 0, 4, "Data Read Success!", WLNORMAL
    Else: rfConsole.RFPrint 0, 4, "Error In Data Read!", WLNORMAL
    End If  ' If strBuffer = "A string representing data to be
            ' stored on an RF device!"

    rfConsole.RFPrint 0, 6, "     Hit a key!     ", WLREVERSE
    rfConsole.RFPrint 0, 9, "", WLNORMAL
    rfConsole.GetEvent
 
' Anytime an application changes the configuration of an RF device,
'  it should return it to its original values during cleanup
    rfFile.RFDeleteFile "FLDemo.Dat"
 
' NOTE : Do NOT use an RFFile object to store the other WaveLink
' objects (menus, tones, & barcodes). Each of these has its own
' methods for interacting with the RF device.
 
ExitApp:
End Sub

VC++ Example

//////////////////////////////////////////////////////////
//        Place RF application's main code here
IRFIO          rfConsole;        // Declare an RFIO interface object
Cstring        csBuffer;         // Storage buffer for data strings
 
    // Create an RFIO object in the automated server for our use
    if (rfConsole.CreateDispatch ("WAVELINKOLE.RFIO") == FALSE) ¿
        return FALSE;
 
    // This application demonstrates the use of the various RFIO
    // 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 RFIO ", ¿
              WLCLEAR | WLREVERSE);
    rfConsole.RFPrint (0, 1, "  Method Demo App   ", 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 object
        rfConsole.ReleaseDispatch ();
        return FALSE;
    } // if ((rfConsole.GetEvent ()).IsEmpty () == TRUE)
    // There are 4 ways data is "flushed" to the RF device's screen:
    //   1. The number of bytes in the output buffer reaches 100;
    //   2. The output mode includes the WLFLUSHOUTPUT constant;
    //   3. A call to the RFFlushoutput method is made;
    //   4. Or, input is requested using the RFInput or GetEvent
    //      methods.
 
    // This demonstrates method 2 (described above)
    rfConsole.RFPrint (0, 0, "  Enter Your Name : ", ¿
              WLCLEAR |  WLFLUSHOUTPUT);
    rfConsole.SetFillChar ("%"); // By default, the fill character
                                 // is "_"
    csBuffer = rfConsole.RFInput ("Your Name",  // Default value
                                                // for input prompt
               14,     // Input field length
               3,      // Input field start column
               2,      // Input field start row (numbered from the
                       // top of the display)
               NULL,   // The barcode configuration file name
                       // (default in this case)
               NORMALKEYS,         // The keyboard state
               WLBACKLIGHT |       // Input mode : Backlight on |
               WLMAXLENGTH |       // Allow a max of 14 characters |
               WLNO_RETURN_BKSP |  // Do not return if Backspace is
                                   // keyed in position 1 |
               WLALPHA_ONLY);      // Since names don't generally
                                   // include numbers, accept
                                   // letters only
    // Check for function or network errors
    if (csBuffer.IsEmpty () == TRUE) {
        // Release the RFIO object
        rfConsole.ReleaseDispatch ();
        return FALSE;
    } // if (csBuffer.IsEmpty () == TRUE)
    else {
        rfConsole.RFPrint (0, 4, CString ("Hello ") + csBuffer, ¿
                  WLFLUSHOUTPUT);
        rfConsole.RFPrint (0, 9, "", WLNORMAL);
        Sleep (2000);  // Allow user to read response
    } // else
 
    // It is often desirable to send data to a printer attached to
    // the RF device
    rfConsole.RFPrint(0, 0, "   Scan A Barcode : ", WLCLEAR);
    rfConsole.SetFillChar("#"); // By default, the fill character
                                // is "_"
    csBuffer = rfConsole.RFInput (NULL, // Default value for input
                                        // prompt
               20,     // Input field length
               0,      // Input field start column
               2,      // Input field start row (numbered from
                       // the top of the display)
               NULL,          // The barcode configuration file
                              // name (default in this case)
               NORMALKEYS,        // The keyboard state
               WLBACKLIGHT |      // Input mode : Backlight on |
               WLDISABLE_KEY |    // Disable normal keyboard input |
               WLFORCE_ENTRY);     // Ensure data will be entered
    // Check for function or network errors
    if (csBuffer.IsEmpty () == TRUE) {
        // Release the RFIO object
        rfConsole.ReleaseDispatch ();
        return FALSE;
    } // if (csBuffer.IsEmpty () == TRUE)
    else {
        rfConsole.RFPrint (0, 4, "Data Entered : ", WLNORMAL);
        rfConsole.RFPrint (0, 5, csBuffer, WLNORMAL);
        rfConsole.RFPrint (0, 9, "", WLFLUSHOUTPUT);
        // Now we shall send it to the printer ...
        if (rfConsole.RFAux (csBuffer) == FALSE) {
            // Display the RFIO error code for RFAux failure
            csBuffer.Format ("Printer Error : %ld", ¿
                     rfConsole.RFRFGetLastError());
            rfConsole.RFPrint (0, 1, csBuffer, WLNORMAL);
            rfConsole.RFPrint (0, 3, "Hit a key to proceed", ¿
                      WLNORMAL);
            rfConsole.RFPrint (0, 9, "", WLNORMAL);
            rfConsole.GetEvent ();         // Wait for single event
        } // if (rfConsole.RFAux (csBuffer) == FALSE)
        Sleep (2000);  // Allow user to read response
    } // else
 
    // Explicitly repainting the same screen multiple times
    // is excessively taxing on the RF network. A faster and more
    // efficient technique is to use the RFPushScreen,
    // RF RestoreScreen & RFPullScreen methods.
    // First, display the desired screen using RFPrint ...
    rfConsole.RFPrint(0, 0, "  This is line one  ", WLCLEAR);
    rfConsole.RFPrint(0, 2, "The quick brown fox ", WLREVERSE);
    rfConsole.RFPrint(0, 3, "jumped over the lazy", WLNORMAL);
    rfConsole.RFPrint(0, 4, "       dog!         ", WLREVERSE);
    rfConsole.RFPrint(0, 7, "Hit a key to proceed", WLNORMAL);
    rfConsole.RFPrint(0, 9, "", WLNORMAL);
    rfConsole.GetEvent();       // Wait for single event
 
    // Second, store the screen on the RF device ...
    rfConsole.PushScreen ("RFIODemo");
 
    // Lastly, restore it at will.
    rfConsole.RFPrint (0, 3, "Hit a key to proceed", WLCLEAR);
    rfConsole.RFPrint (0, 9, "", WLNORMAL);
    rfConsole.GetEvent ();      // Wait for single event

    rfConsole.PullScreen ("RFIODemo");
    rfConsole.GetEvent ();      // Wait for single event

// NOTES:
//  1. It is not necessary to use GetEvent to flush the output;
//     PullScreen displays the screen automatically. We are just
//     allowing the user to view the restored screen before exiting
//
//  2. The screen file is deleted when the PullScreen method
//     is used. If the screen must be restored repeatedly, use
//     RestoreScreen (which does NOT delete it) until
//     it is no longer needed.
 
    // Release the RFIO object
    rfConsole.ReleaseDispatch ();

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal