RFFile Samples

Using both Visual Basic and Visual C++ sample code, the following set of applications will demonstrate the use and capabilities of the RFFile object and its methods. Both applications will list the current files on an RF device, save a new file to the device, then delete the file from the device.

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

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

 

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal