RFError Samples

Using both Visual Basic and Visual C++ sample code, the following set of applications demonstrate the use of the RFError object and its methods.

Visual Basic Sample

' RFError 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 RFError object for use throughout the
' demo application.
Public rfErr As New RFERROR
' strBuffer is a temp storage buffer
Dim strBuffer As String
 
Dim nLcv As Integer
 
Public Sub Main()
 
' This application demonstrates the use of the various RFError
' 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, "RFError 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() = "" Then
' During the course of any application, there will be times
' when you wish to notify a user of an error condition which has
' arisen. The RFError object is the preferred method for doing
' this over an RF network.
'
' The first sample will define and display an error message for 2
' seconds
    rfErr.SetErrorLine " This error will ", 0
    rfErr.SetErrorLine "  display for 2  ", 1
    rfErr.SetErrorLine "     seconds     ", 2
'
    If rfErr.Display(2) = False Then
        GoTo ExitApp
    End If  ' if rfErr.Display (2) = False
'
' Now we will define and display an error message, but require the
' user to acknowledge the error by pressing the CLR (Escape) key by
' setting a zero (0) timeout.
    rfErr.ClearError
    rfErr.SetErrorLine "Acknowledge this", 1
    rfErr.SetErrorLine " error, please. ", 2
    rfErr.SetErrorLine " ", 3
 
    If rfErr.Display(0) = False Then
        GoTo ExitApp
    End If  ' if rfErr.Display (0) = False

' When an application must perform an extended operation, it is
' usually a good idea to provide the user with a visual indicator
' of progress.
    rfConsole.RFPrint 0, 0, " Preforming a time- ", WLCLEAR
    rfConsole.RFPrint 0, 1, "   consuming job!   ", WLFLUSHOUTPUT
'
    rfErr.ClearError
    For nLcv = 10 To 100 Step 10
        strBuffer = " " + Format(nLcv / 100, "0.00%") + " Complete "
        rfErr.SetErrorLine strBuffer, 0
        rfErr.SetErrorLine " <CLR> To Cancel. ", 1
        If rfErr.Display(1) = False Then
            GoTo ExitApp
        End If  ' if rfError.Display (1) = False
        If rfConsole.TellEvent() <> "" Then
            strBuffer = rfConsole.GetEvent()
            If Asc(strBuffer) = 27 Then
                GoTo ExitApp
            End If  'If Asc(strBuffer) = 27
        End If  ' If rfConsole.TellEvent() <> "" Then
        Call Sleep(2000)
    Next nLcv
 
ExitApp:
End Sub

Visual C++ Example

//////////////////////////////////////////////////////////
//           Place RF application's main code here
IRFIO        rfConsole;       // Declare an RFIO interface object
IRFError     rfError;         // Declare an RFError 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;
    // Create an RFError object in the automated server for our use
    if (rfError.CreateDispatch ("WAVELINKOLE.RFERROR") == FALSE) {
        // Release the RFIO object
        rfConsole.ReleaseDispatch ();
        return FALSE;
    } // if (rfError.CreateDispatch ("WAVELINKOLE.RFERROR") ¿
                     == FALSE)
 
    // This application demonstrates the use of the various RFError
    // 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, "RFError 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 & RFError objects
        rfConsole.ReleaseDispatch ();
        rfError.ReleaseDispatch ();
        return FALSE;
    } // if ((rfConsole.GetEvent ()).IsEmpty () == TRUE)
 
    // During the course of any application, there will be times
    // when you wish to notify a user of an error condition which
    // has arisen. The RFError object is the preferred method for
    // doing this over an RF network.

    // The first sample will define and display an error message
    // for 2 seconds
    rfError.SetErrorLine (" This error will ", 0);
    rfError.SetErrorLine ("  display for 2  ", 1);
    rfError.SetErrorLine ("     seconds     ", 2);
 
    if (rfError.Display (2) == FALSE) {
        // Release the RFIO & RFError objects
        rfConsole.ReleaseDispatch ();
        rfError.ReleaseDispatch ();
        return FALSE;
    } // if (rfError.Display (2) == FALSE)

    // Now we will define and display an error message, but
    // require the user to acknowledge the error by pressing
    // the CLR (Escape) key by setting a zero (0) timeout.
    rfError.ClearError ();
    rfError.SetErrorLine ("Acknowledge this", 1);
    rfError.SetErrorLine (" error, please. ", 2);
    rfError.SetErrorLine (" ", 3);
 
    if (rfError.Display (0) == FALSE) {
        // Release the RFIO & RFError objects
        rfConsole.ReleaseDispatch ();
        rfError.ReleaseDispatch ();
        return FALSE;
    } // if (rfError.Display (0) == FALSE)

    // When an application must perform an extended operation,
    // it is usually a good idea to provide the user with a
    // visual indicator of progress.
    rfConsole.RFPrint (0, 0, " Preforming a time- ", WLCLEAR);
    rfConsole.RFPrint (0, 1, "   consuming job!   ", WLFLUSHOUTPUT);
 
    rfError.ClearError ();
    for (int nLcv = 0; nLcv <= 100; nLcv += 10) {
        csBuffer.Format ("  %%%03d Complete  ", nLcv);
        rfError.SetErrorLine (csBuffer, 0);
        rfError.SetErrorLine (" <CLR> To Cancel. ", 1);
        if (rfError.Display (1) == FALSE) {
            // Release the RFIO & RFError objects
            rfConsole.ReleaseDispatch ();
            rfError.ReleaseDispatch ();
            return FALSE;
        } // if (rfError.Display (1) == FALSE)
        if ((rfConsole.TellEvent ()).IsEmpty () == FALSE) {
            csBuffer = rfConsole.GetEvent ();
            if (csBuffer [0] == char(27)) break;
        } // if (rfConsole.TellEvent ()).IsEmpty () == FALSE)
        Sleep (2000);
    } // for (int nLcv = 0; nLcv <= 100; nLcv += 10)
 
    // Release the RFIO & RFError objects
    rfConsole.ReleaseDispatch ();
    rfError.ReleaseDispatch ();

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal