RFMenu Samples

Using both Visual Basic and Visual C++ sample code, the following set of applications will demonstrate the implementation and capabilities of the RFMenu object and its methods. Both applications will store a menu with eight options on an RF device, return any user selection, then delete the menu from the device when the application is finished.

VB Example

' RFMenu 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 RFMenu object for use throughout the
' demo application.
Public rfMnu As New RFMENU
' strBuffer is a temp storage buffer
Dim strBuffer As String
' bDone is a loop control variable
Dim bDone As Boolean
' nTmp is a temporary integer
Dim nTmp As Integer
 
 
Public Sub Main()
' This application demonstrates the use of the various RFMenu
' 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, "    RFMenu 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() = ""
' Menus are useful for providing users with choices at run time
' without excessive RF traffic. During an application's
' initialization, one can store the static menus used by the app
' all at once. Then when needed, the application can execute them
' at will.
      
' To demonstrate their use, add some options to the RFMenu object ...
    rfMnu.ResetMenu           ' Not necessary with a new object, 
                              ' but not a bad habit to acquire.
    rfMnu.AddOption "Option 1"
    rfMnu.AddOption "Option 2"
    rfMnu.AddOption "Option 3"
    rfMnu.AddOption "Option 4"
    rfMnu.AddOption "Option 5"
    rfMnu.AddOption "Option 6"
    rfMnu.AddOption "Option 7"
    rfMnu.AddOption "Option 8"
 
' and a title line or two ...
    rfMnu.AddTitleLine "RFMenu OLE Object"
    rfMnu.AddTitleLine "  Demonstration  "
      
' When storing the menu on the RF device, the library will place
' the menu in the upper left corner of the display and size it to
' height of the screen or height of the menu (options & title)
' if those values are set to 0. For this demo, we will be setting
' the values to see how the methods are used.
    rfMnu.SetStartColumn 0           ' The default value
    rfMnu.SetStartRow 1
    rfMnu.SetMenuWidth 20      ' The default value is the screen
                               ' width for the particular RF device
    rfMnu.SetMenuHeight 6      ' See above for discussion of this
                               ' value
' NOTE: One could set all these values using the SetCoordinates
' method:
'      rfMnu.SetCoordinates (0, 1, 20, 6);
 
' The menu must be stored on the RF device before it may be used.
    If rfMnu.StoreMenu("MenuDemo") = False Then
        GoTo ExitApp
    End If  ' If rfMnu.StoreMenu("MenuDemo") = False
 
' The following loop iterates while bDone == FALSE. It displays
' the stored menu, awaits the user's selection and displays
' the choice index and string value.
    bDone = False
    While bDone = False
        nTmp = rfMnu.DoMenu("MenuDemo")
        Select Case nTmp
        Case -2     ' An error has occurred
            strBuffer = "RFMenu Error : " + rfMnu.RFGetLastError()
            rfConsole.RFPrint 0, 3, strBuffer, WLCLEAR + WLNORMAL
            rfConsole.RFPrint 0, 7, "Hit a key to proceed", WLNORMAL
            ' Hide the cursor for a cleaner display
            rfConsole.RFPrint 0, 9, "", WLNORMAL
            rfConsole.GetEvent
 
        Case -1     ' CLR or CTL + 'X' was keyed
            bDone = True
 
        Case Else   ' User selected an option
            strBuffer = Str(nTmp) + " -> " + _
                        rfMnu.GetMenuOption(nTmp)
            rfConsole.RFPrint 0, 3, strBuffer, WLCLEAR + WLNORMAL
            rfConsole.RFPrint 0, 7, "Hit a key to proceed", WLNORMAL
            ' Hide the cursor for a cleaner display
            rfConsole.RFPrint 0, 9, "", WLNORMAL
            rfConsole.GetEvent
        End Select  ' Select Case nTmp
    Wend    ' While bDone = False
 
' Anytime an application changes the configuration of an RF device,
' it should return it to its original values during cleanup
    rfMnu.DeleteMenu "MenuDemo"
 
ExitApp:
End Sub

VC++ Example

//////////////////////////////////////////////////////////
//    Place RF application's main code here
IRFIO       rfConsole;      // Declare an RFIO interface object
IRFMenu     rfMenu;         // Declare an RFMenu interface object
Cstring     csBuffer;       // Storage buffer for data strings
Short       nTmp;           // Temporary short value
BOOL        bDone;          // Denotes the user's desire to end
                            // the application
 
    // Create an RFIO object in the automated server for our use
    if (rfConsole.CreateDispatch ("WAVELINKOLE.RFIO") == FALSE) ¿
        return FALSE;
    // Create an RFMenu object in the automated server for our use
    if (rfMenu.CreateDispatch ("WAVELINKOLE.RFMENU") == FALSE) {
        // Release the RFIO object
        rfConsole.ReleaseDispatch ();
        return FALSE;
    } // if (rfTone.CreateDispatch ("WAVELINKOLE.RFMENU") == FALSE)
 
    // This application demonstrates the use of the various RFMenu
    // 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, " RFMenu 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 ()).IsEmpty () == TRUE) {
        // Release the RFIO & RFMenu objects
        rfConsole.ReleaseDispatch ();
        rfMenu.ReleaseDispatch ();
        return FALSE;
    } // if ((rfConsole.GetEvent ()).IsEmpty () == TRUE)
 
    // Menus are useful for providing users with choices at run
    // time without excessive RF traffic. During an application's
    // initialization, one can store the static menus used by the
    // app all at once. Then when needed, the application can 
    // execute them at will.
     
    // To demonstrate their use, add some options to the RFMenu
    // object ...
    rfMenu.ResetMenu (); // Not necessary with a new object,
                         // but not a
                         // bad habit to acquire.
    rfMenu.AddOption ("Option 1");
    rfMenu.AddOption ("Option 2");
    rfMenu.AddOption ("Option 3");
    rfMenu.AddOption ("Option 4");
    rfMenu.AddOption ("Option 5");
    rfMenu.AddOption ("Option 6");
    rfMenu.AddOption ("Option 7");
    rfMenu.AddOption ("Option 8");
 
    // and a title line or two ...
    rfMenu.AddTitleLine ("RFMenu OLE Object");
    rfMenu.AddTitleLine ("  Demonstration  ");
  
    // When storing the menu on the RF device, the library will
    // place the menu in the upper left corner of the display and
    // size it to the height of the screen or the height of the menu
    // (options & title) if those values are set to 0. For
    //  this demo, we will be setting the values to see how the
    // methods are used.
    rfMenu.SetStartColumn (0);     // The default value
    rfMenu.SetStartRow (1);
    rfMenu.SetMenuWidth (20);      // The default value is the
                                   // screen width for the
                                   // particular RF device
    rfMenu.SetMenuHeight (6);      // See above for discussion of
                                   // this value
    // NOTE: One could set all these values using the
    // SetCoordinates method:
    //      rfMenu.SetCoordinates (0, 1, 20, 6);
 
    // The menu must now be stored on the RF device before it
    // may be used.
    if (rfMenu.StoreMenu ("MenuDemo") == FALSE) {
        // Release the RFIO & RFMenu objects
        rfConsole.ReleaseDispatch ();
        rfMenu.ReleaseDispatch ();
        return FALSE;
    } // if (rfMenu.StoreMenu ("MenuDemo") == FALSE) 
 
    // The following loop iterates while bDone == FALSE. It displays
    // the stored menu, awaits the user's selection and displays the
    // choice index and string value.
    bDone = FALSE;
    while (bDone == FALSE) {
        switch (nTmp = rfMenu.DoMenu ("MenuDemo")) {
        case -2 :      // An error has occurred
            csBuffer.Format ("RFMenu Error : %ld", ¿
                     rfMenu.RFRFGetLastError());
            rfConsole.RFPrint (0, 3, csBuffer, WLCLEAR | WLNORMAL);
            rfConsole.RFPrint (0, 7, "Hit a key to proceed", ¿
                      WLNORMAL);
            // Hide the cursor for a cleaner display
            rfConsole.RFPrint (0, 9, "", WLNORMAL);
            rfConsole.GetEvent ();
 
        case -1 :       // CLR or CTL + 'X' was keyed
            bDone = TRUE;
            break;
 
        default :       // User selected an option
            csBuffer.Format ("%d -> %s", nTmp, ¿
                     rfMenu.GetMenuOption (nTmp));
            rfConsole.RFPrint (0, 3, csBuffer, WLCLEAR | WLNORMAL);
            rfConsole.RFPrint (0, 7, "Hit a key to proceed", ¿
                      WLNORMAL);
            // Hide the cursor for a cleaner display
            rfConsole.RFPrint (0, 9, "", WLNORMAL);
            rfConsole.GetEvent ();
            break;
        } // switch (nTmp = rfMenu.DoMenu ("MenuDemo"))
    } // while (bDone == FALSE)
 
    // Anytime an application changes the configuration of an RF
    // device, it should return it to its original values during
    // cleanup
    rfMenu.DeleteMenu ("MenuDemo");
 
    // Release the RFIO & RFMenu objects
    rfConsole.ReleaseDispatch ();
    rfMenu.ReleaseDispatch ();


 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal