Entry point for the sample program

The sample program will drive the Content Manager OnDemand Windows client by using the DDE interface.

Some important things to note:
  • The commands sent to the Content Manager OnDemand client are not DDE EXECUTE's, they are all DDE REQUEST's. This is important because sending DDE EXECUTE's to the Content Manager OnDemand client results in an error.
  • It is important to start the Content Manager OnDemand client with at least the /I option. This enables the DDE interface of the Content Manager OnDemand client. (See the globals section to see what options were used for the VBDEMO.)
The sample program was written using Visual Basic 5.0 (32-bit). The txtDemo control (which is hidden) is used as the DDE client in the DDE conversation with the Content Manager OnDemand client window. In fncDDElink(), you will see where we setup this control to perform the DDE request and that the data comes back to this control. Therefore any data returned by the Content Manager OnDemand client window has to be parsed from out of this control.
Sub Main()
    Dim rc As Integer

    'Initialize globals and read in data from ini file(s).
    Call fncInit

    frmStatusDlg.lblStatus.Caption = "Starting client..."
    frmStatusDlg.Show 0

    'Start Content Manager OnDemand client.
    Shell (guipath + arsgui + arsguiopts)

    'Logon to the server (logon information was gathered from ini
    'file during fncInit. User cannot do anything else while this
    'is going on. Try to use SetFocusAPI() to restore focus to our
    'status message while this is going on.
    frmStatusDlg.lblStatus.Caption = "Logging on to Server..."
    Call frmCreditV1.fncLogon
    rc = SetFocusAPI(frmStatusDlg.hWnd)

    'Open the "Baxter Bay Credit" folder
    frmStatusDlg.lblStatus.Caption = "Opening folder..."
    Call frmCreditV1.fncOpenFolder

    'Don't need the status message box any more.
    frmStatusDlg.Hide

    'Only after we have logged on and opened the folder do we
    'display the VBDEMO form.
    frmCreditV1.Show 1

End Sub

'Send DDE REQUEST of CLOSE_ALL_DOCS to the client window:

Private Sub fncCloseDoc()
    Dim cmdline, qrc As String

    Call fncDispStatus("Close all open docs...")
    cmdline = "CLOSE_ALL_DOCS"
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    qrc = fncGetrc(txtDemo)
    If qrc <> "0" Then
        Call quit(cmdline, qrc)
    End If

    Call fncDispStatus("All open docs closed.")
End Sub

'This procedure handles the link to the Content Manager OnDemand client.
' Topic should come in as ARS|ARS, this is the app name and topic name.

Private Sub fncDDElink(ByVal topic As String, ByVal cmnd As String,
   ByVal mode As Integer, ByVal waittime As Integer)
'Setup local variables
    Dim sync, lntxtDemo, i, rc As Integer
    Dim workchar, workline, msg As String
'Set up error handler to show contact errors
    On Error GoTo HandleError
'Set up DDE link and pass required data:
    txtDemo = "-"
    txtDemo.LinkTimeout = waittime
    txtDemo.LinkTopic = topic
    txtDemo.LinkItem = cmnd
    txtDemo.LinkMode = mode
    'Calling LinkRequest performs the request.
    txtDemo.LinkRequest
Exit Sub

HandleError:
    'Handle DDE errors
    rc = Err
    Select Case rc
        Case 280 To 297
        Select Case rc
          Case 280
            msg = "DDE channel not closed; awaiting response from foreign application"
          Case 281
            msg = "No more DDE channels"
          Case 282
            msg = "DDE requests are being refused"
          Case 283
            msg = "Too many apps responded"
          Case 284
            msg = "DDE channel locked"
          Case 285
            msg = "App is not accepting DDE requests...' "
        End Select
        Case Else
          msg = "Non-DDE error occurred " + Str(rc)
    End Select
    MsgBox msg
    Resume Next
End Sub

'Used to send DDE REQUEST command of ACTIVATE_DOC or OPEN_DOC to
' the Content Manager OnDemand client.

Private Sub fncDispDoc(ByVal docnum As Integer)
    Dim cmdline, qrc As String

    'If the document the user is requesting to be displayed has
    'previously been opened, then use ACTIVATE_DOC to redisplay
    'it, otherwise we will need to OPEN_DOC and store away the
    'document id.
    'If the user closes the document view from the client interface
    'we need to be notified of this event so that we can update
    'our doc_id array. Currently the client does not support this.

    If doc_ids(docnum) <> "0" Then
        Call fncDispStatus("Activating the document...")
        cmdline = "ACTIVATE_DOC /D " + doc_ids(docnum)
        Call fncDDElink(arstopic, cmdline, linktype, 3000)
        qrc = fncGetrc(txtDemo)
        If qrc <> "0" Then
            'The user possibly closed the view from the client,
            'reset the document id to 0 and tell the user to try again.
            doc_ids(docnum) = "0"
            Call fncDispStatus("Activating the document...ERROR")
            MsgBox "Could not activate, try to view again!"
            Exit Sub
        End If
        Call fncDispStatus("Activating the document...done")
    Else
        'Open the document
        Call fncDispStatus("Open the document...")
        cmdline = "OPEN_DOC /N " + Str(docnum)
        Call fncDDElink(arstopic, cmdline, linktype, 3000)
        qrc = fncGetrc(txtDemo)
        If qrc <> "0" Then
            Call quit(cmdline, qrc)
        End If
        doc_ids(docnum) = fncGetdochandle(txtDemo)
        Call fncDispStatus("Open the document...done.")
    End If

'Make the display visible
    Call fncDispStatus("Opening the display...")
    cmdline = "SHOW_WINDOW /W"
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    qrc = fncGetrc(txtDemo)
    If qrc <> "0" Then
        Call quit(cmdline, qrc)
    End If
    Call fncDispStatus("Opening the display...done.")

    Call fncDispStatus("Document retrieval complete.")
End Sub

'Obtains the hitlist of documents from the Content Manager OnDemand client.
Private Sub fncGetHitlist()
    Dim cmdline, qrc As String
    Dim num_docs As Integer

    'Get the number of documents which matched the search
    'criteria.
    cmdline = "GET_NUM_DOCS_IN_LIST"
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    num_docs = CInt(Mid(txtDemo, 3, 10))
    If num_docs = 0 Then
        MsgBox "No documents found matching search criteria!"
        Exit Sub
    End If

    Call fncDispStatus("Getting account information...")

    'Get the first document and parse its data to display
    cmdline = "GET_DOC_VALUES /N 0"
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    Call fncExtract(txtDemo.Text)
    'Display its data
    pnlPayData1.Caption = txtStack(1)
    Panel3D1.Caption = txtStack(4)
    'Add about 20 days or so to the statement date'
    Panel3D2.Caption = fncParseDate(txtStack(1))
    cmdViewStmt1.Enabled = True

    'If there are at least two documents then get number 2
    If num_docs > 1 Then
        cmdline = "GET_DOC_VALUES /N 1"
        Call fncDDElink(arstopic, cmdline, linktype, 3000)
        Call fncExtract(txtDemo.Text)
        'Display its data
        pnlPayData2.Caption = txtStack(1)
        Panel3D3.Caption = txtStack(4)
        'Add about 20 days or so to the statement date'
        Panel3D4.Caption = fncParseDate(txtStack(1))
        cmdViewStmt2.Enabled = True
    Else
        'There was only 1 document so disable 2nd "View" button.
        cmdViewStmt2.Enabled = False
    End If

'If there are at least three documents then get number 3
    If num_docs > 2 Then
        cmdline = "GET_DOC_VALUES /N 2"
        Call fncDDElink(arstopic, cmdline, linktype, 3000)
        Call fncExtract(txtDemo.Text)
        'Display its data
        pnlPayData3.Caption = txtStack(1)
        Panel3D5.Caption = txtStack(4)
        'Add about 20 days or so to the statement date'
        Panel3D6.Caption = fncParseDate(txtStack(1))
        cmdViewStmt3.Enabled = True

Else
        'There were only 2 documents so disable 3rd "View" button.
        cmdViewStmt3.Enabled = False
    End If
    Call fncDispStatus("Getting account information...done.")
End Sub

'Procedure used to hide the Content Manager OnDemand client window.
'Sends a DDE REQUEST message of SHOW_WINDOW to the client.
Private Sub fncHideWindow()
    Dim cmdline, qrc As String

    cmdline = "SHOW_WINDOW /W N"
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    qrc = fncGetrc(txtDemo)
    If qrc <> "0" Then
        Call quit(cmdline, qrc)
    End If
End Sub

'Logon to the Content Manager OnDemand client.
Public Sub fncLogon()
    Dim cmdline, qrc As String

    Call fncDispStatus("Logon to Client...")
    cmdline = "LOGON /S " + server + " /U " + userid + " /P " + pass
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    qrc = fncGetrc(txtDemo)
    If qrc <> "0" Then
        'If we fail the logon the client will display his logon dialog.
        'We will not return from this DDE call until the user either
        'successfully log's onto a server or cancel's the process, in
        'which case we end up with an error code and inside of this If
        'statement. Close the client and then ourselves.
        'I am not sure if the above statement is valid if you started up
        ' the Content Manager OnDemand client with the Disable anticipation (/V) parameter.
        Call fncDDElink(arstopic, "EXIT", linktype, 3000)
        Call fncDispStatus("Logon to client...failed.")
        End
    End If
    Call fncDispStatus("Logon to Client...done.")
End Sub

'Open up a Content Manager OnDemand folder.
Public Sub fncOpenFolder()
  Dim cmdline, qrc As String

  Call fncDispStatus("Open the folder...")
  cmdline = "OPEN_FOLDER /F " + folder
  Call fncDDElink(arstopic, cmdline, linktype, 3000)
  qrc = fncGetrc(txtDemo)
  If qrc <> "0" Then Call quit(cmdline, qrc)
  Call fncDispStatus("Open the folder...done.")

End Sub

'Search the Content Manager OnDemand folder for documents.
Private Sub fncSearchDoc(ByVal AcctNum As String)
    Dim cmdline, qrc As String

    'Setup our search fields with the client.
    Call fncDispStatus("Setting up Search...")
    cmdline = "SET_FIELD_DATA /F Account /1 " + AcctNum
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    qrc = fncGetrc(txtDemo)
    If qrc <> "0" Then
        Call quit(cmdline, qrc)
    End If
    Call fncDispStatus("Setting up Search...done.")

    'Have the client perform the search.
    Call fncDispStatus("Performing the Search...")
    cmdline = "SEARCH_FOLDER"
    Call fncDDElink(arstopic, cmdline, linktype, 3000)
    qrc = fncGetrc(txtDemo)
    If qrc <> "0" Then
        Call quit(cmdline, qrc)
    End If
    Call fncDispStatus("Performing the Search...done.")
End Sub

'Performs three DDE steps for us:
'    - Inform client to retrieve selected document.
'    - Enable the switch back toolbar button on the clients toolbar so that the
'      user can get back easily to the VBDEMO.
'    - Switch focus to the client.
Private Sub fncViewDoc(ByVal docnum As Integer)
    'Setup local variables
    Dim MyHandle As Integer

    'Display the document
    Call fncDispDoc(docnum)
    'Activate DDE and transfer Focus to Content Manager OnDemand
    MyHandle = frmCreditV1.hWnd
    Call fncDDElink(arstopic, "ENABLE_SWITCH /H " + Str(MyHandle) + " /C " + apptitle,
 linktype, 3000)
    Call fncDDElink(arstopic, "SET_FOCUS", linktype, 3000)
End Sub

'Displays error code.
Private Sub quit(ByVal qinfo As String, ByVal qrc As String)
    Dim quitstring As String

    quitstring = "Error encountered: " + qinfo + " rc=" + qrc
    MsgBox quitstring
    End
End Sub

'GUI control used to display customer information.
'We do not obtain the customer information from out of Content Manager OnDemand, it is
'  not stored there. The normal way to obtain this information would be
'  to get it out of your business database. After which you would look up
'  the customer statements in Content Manager OnDemand. We simply get this information from
'  out of an ini file.
Private Sub cmdCustInfo_Click()
    Dim acct_num, ini_str As String
    Dim cmdline, qrc As String
    Dim rc As Integer
    Dim first_num, second_num, third_num As Integer

    'Zero out the Payment record fields before retrieving new customer
    pnlPayData1.Caption = ""
    Panel3D1.Caption = ""
    Panel3D2.Caption = ""
    pnlPayData2.Caption = ""
    Panel3D3.Caption = ""
    Panel3D4.Caption = ""
    pnlPayData3.Caption = ""
    Panel3D5.Caption = ""
    Panel3D6.Caption = ""
    'Zero out the Customer Information fields.
    pnlNameData.Caption = ""
    pnlSSNData.Caption = ""
    pnlDOBData.Caption = ""
    pnlMNameData.Caption = ""
    pnlAddrData1.Caption = ""
    pnlAddrData2.Caption = ""
    pnlPhoneData.Caption = ""

'Disable "View" buttons
    cmdViewStmt1.Enabled = False
    cmdViewStmt2.Enabled = False
    cmdViewStmt3.Enabled = False

    'Hide client window
    Call fncHideWindow

    'Look up the account number, contained in the pnlAcctnumData text field
    'in the arsvblan.ini file. If found, read the respective
    'fields. If not found display error message.
    acct_num = txtAcctnumData.Text

    'Do at least a little validation.
    If Len(acct_num) <> 11 Then
        MsgBox "Correct format for account # is 000-000-000"
        Exit Sub
    End If

'If we have gotten to here we know that we have an account
    'number of the format 000-000-000. If either of the first
    'two sections of the number are nonzero or if the third
    'section is not between 001-046 then default to the account
    'number 000-000-001.
    first_num = Int(Mid(acct_num, 1, 3))
    second_num = Int(Mid(acct_num, 5, 3))
    third_num = Int(Mid(acct_num, 9, 3))
    If first_num <> 0 Or second_num <> 0 Or third_num > 46 Then
        acct_num = "000-000-001"
    ElseIf third_num = 0 Then
        MsgBox "Invalid account number!"
        Exit Sub
    End If

    ini_str = fncParmGet(acct_num, "Name", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'Name' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub
    End If
    pnlNameData.Caption = "  " + ini_str

    ini_str = fncParmGet(acct_num, "SSN", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'SSN' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub
    End If
    pnlSSNData.Caption = "  " + ini_str

    ini_str = fncParmGet(acct_num, "DOB", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'DOB' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub
    End If
    pnlDOBData.Caption = "  " + ini_str

    ini_str = fncParmGet(acct_num, "MaidenName", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'MaidenName' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub

End If
    pnlMNameData.Caption = "  " + ini_str

    ini_str = fncParmGet(acct_num, "StreetAddress", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'StreetAddress' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub
    End If
    pnlAddrData1.Caption = "  " + ini_str

    ini_str = fncParmGet(acct_num, "CityStateZip", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'CityStateZip' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub
    End If
    pnlAddrData2.Caption = "  " + ini_str

    ini_str = fncParmGet(acct_num, "PhoneNum", ininame)
    If Len(ini_str) = 0 Then
        MsgBox "'PhoneNum' field not found for acct#" + acct_num + "in " + ininame
        Exit Sub
    End If
    pnlPhoneData.Caption = "  " + ini_str

'We are changing customer accounts so before we get new customer
    'information, close old customers open documents.
    If doc_ids(0) <> "0" Or doc_ids(1) <> "0" Or doc_ids(2) <> "0" Then
        doc_ids(0) = "0"
        doc_ids(1) = "0"
        doc_ids(2) = "0"
        cmdline = "CLOSE_ALL_DOCS"
        Call fncDDElink(arstopic, cmdline, linktype, 3000)
        qrc = fncGetrc(txtDemo)
        If qrc <> "0" Then
            Call quit(cmdline, qrc)
        End If
    End If

    'Set up the search fields and perform search.
    Call fncSearchDoc(acct_num)

    'Get the 3 most recent statements.
    Call fncGetHitlist

    'Give ourselves back the focus
    rc = SetFocusAPI(frmCreditV1.hWnd)
End Sub

'User has chosen to exit the VBDEMO. Before exiting close down the client.
Private Sub cmdExit_Click()
    Dim Content Manager OnDemandHandle As Integer

    Call fncDispStatus("Program ending...")

    'Determine if Content Manager OnDemand is loaded
    Content Manager OnDemandHandle = GetModuleHandle(arsgui)
    'If not loaded, then quit, else shutdown
    If Content Manager OnDemandHandle > 0 Then
        Call fncDispStatus("Shutting Client Down...")
        Call fncDDElink(arstopic, "EXIT", linktype, linktime)
    End If

    'Terminate the VBDEMO
    End
End Sub

'View button number 1. Have the client retrieve the first document in
'  the hitlist and display it.
Private Sub cmdViewStmt1_Click()

  Call fncViewDoc(0)

End Sub

'View button number 2. Have the client retrieve the second document in
'  the hitlist and display it.
Private Sub cmdViewStmt2_Click()

  Call fncViewDoc(1)

End Sub

'View button number 3. Have the client retrieve the third document in
'  the hitlist and display it.
Private Sub cmdViewStmt3_Click()

  Call fncViewDoc(2)

End Sub

'If the user is not using the Exit button to close down the demo
'  this function will be called as a result of the form being unloaded
'  so go ahead and shut down the client then exit.
Private Sub Form_Unload(Cancel As Integer)
    Dim Content Manager OnDemandHandle As Integer

    Call fncDispStatus("Program ending...")

    'Determine if Content Manager OnDemand is loaded
    Content Manager OnDemandHandle = GetModuleHandle(arsgui)
    'If not loaded, then quit, else shutdown
    If Content Manager OnDemandHandle > 0 Then
        Call fncDispStatus("Shutting Client Down...")
        Call fncDDElink(arstopic, "EXIT", linktype, linktime)
    End If

    'Terminate the VBDEMO
    End
End Sub

'Make sure that the data they are entering for the account number
'  is valid.
Private Sub txtAcctnumData_KeyPress(KeyAscii As Integer)

    Dim pos As Integer

    pos = txtAcctnumData.SelStart

    Select Case KeyAscii
        Case 48 To 59
            'pos must be 0-2, 4-6, 8-10
            Select Case pos
                Case 0 To 2, 4 To 6, 8 To 10
                    'OK
                Case Else
                    Beep
                    KeyAscii = 0
            End Select
        Case 45              ' the - character
            'pos must be 3 or 7
            If pos <> 3 And pos <> 7 Then
                Beep
                KeyAscii = 0
            End If
        Case 8, 127
            'Just let these through.
        Case Else
            Beep
            KeyAscii = 0
    End Select

End Sub

'This procedure fills in the status line on the form and left adjusts.
Public Sub fncDispStatus(ByVal status As String)
    frmCreditV1.pnlStatus.Caption = status + Space$(255)
End Sub

'This procedure breaks out the words of the input
'string. Words must be delimited by a tab character.
'The words are stored in the global string array txtStack.
Sub fncExtract(ByVal workstring As String)
    Dim txtptr, lenstring, i As Integer
    Dim tabchar, workline, workchar As String

    txtptr = 0
    tabchar = Chr(9)
    workline = ""
    lenstring = Len(workstring)
    workstring = Mid$(workstring, 3, lenstring)

'Extract chars to the first blank
    For i = 1 To lenstring
        workchar = Mid$(workstring, i, 1)
        'When a tab is found, store result, reset
        If workchar = tabchar Then
            txtptr = txtptr + 1
            txtStack(txtptr) = workline
            workline = ""
        'Otherwise, keep building the work string
        Else
            workline = workline + workchar
        End If
    Next

    If Len(workline) > 0 Then
        txtptr = txtptr + 1
        txtStack(txtptr) = workline
    End If
End Sub

'This function extracts out the document handle from the
'return string.
Function fncGetdochandle(ByVal workstring As String)
    Dim lenstring, first, i As Integer
    Dim rc, workline, workchar As String

'Set the return code for invalid function call
    rc = "999"
    first = yes
    workstring = Trim$(workstring)
    lenstring = Len(workstring)

'Extract chars to the first blank
    If lenstring > 0 Then
        workline = ""
        For i = 1 To lenstring
            workchar = Mid$(workstring, i, 1)
            'When a second blank is found, stop
            If workchar = " " Then
                If first = yes Then
                    first = no
                    workline = ""
                Else
                    rc = workline
                    i = leave
                End If
            'Otherwise build up return code
            Else
                workline = workline + workchar
            End If
        Next
        'If the doc handle has been built, assign it
        If workline <> "" Then
            rc = workline
        End If
    End If

    'Set the function return value
    fncGetdochandle = rc

End Function

'This function extracts out the return code from the
'return string.
Function fncGetrc(ByVal workstring As String)
    Dim lenstring, i As Long
    Dim rc, workline, workchar As String

    'Set the return code for invalid function call
    rc = "999"
    workstring = Trim$(workstring)
    lenstring = Len(workstring)

    'Extract chars to the first blank
    If lenstring > 0 Then
        workline = ""
        For i = 1 To lenstring
            workchar = Mid$(workstring, i, 1)
            'When a blank is found, stop
            If workchar = " " Then
                rc = workline
                i = leave
            'Otherwise build up return code
            Else
                workline = workline + workchar
            End If
        Next
        'If a return code has been built, assign it
        If workline <> "" Then
            rc = workline
        End If
    End If

    'Set the function return value
    fncGetrc = rc

End Function

'Perform global initialization
Sub fncInit()
    Dim ini_str As String

    'Set document ids for all three to 0
    doc_ids(0) = "0"
    doc_ids(1) = "0"
    doc_ids(2) = "0"

    'Disable "View" buttons
    frmCreditV1.cmdViewStmt1.Enabled = False
    frmCreditV1.cmdViewStmt2.Enabled = False
    frmCreditV1.cmdViewStmt3.Enabled = False

    'The VBDEMO keyword in the PATHS stanza of the ars.ini file
    'points to the .ini file where the other
    'demo settings can be picked up. If the
    'VBDEMO keyword cannot be found, the ini
    'file is set to arsvblan.ini.

    'Try to find vbdemo inifile name
    ininame = defini
    ini_str = fncParmGet("PATHS", "VBDEMO", "ars.ini")
    'If the ini name is found, then set
    If Len(ini_str) > 0 Then
        ininame = ini_str
    End If

    'Try to find arsgui execution path
    ini_str = fncParmGet(defstanza, "GUIPath", ininame)
    'If it can't be found, check for an env var
    If Len(ini_str) = 0 Then
        MsgBox "Cannot find GUIPath in " + ininame
    End If

    'If the path is found, then set
    If Len(ini_str) > 0 Then
        guipath = ini_str + "\"
    End If

    'Try to find the server in the ars ini file
    ini_str = fncParmGet(defstanza, "Server", ininame)
    'If it can't be found, check for an env var
    If Len(ini_str) = 0 Then
        MsgBox "Cannot find Server in " + ininame
    End If
    If Len(ini_str) > 0 Then
        server = ini_str
    End If

'Try to find the userid in the ars ini file
    ini_str = fncParmGet(defstanza, "Userid", ininame)
    'If it can't be found, check for an env var
    If Len(ini_str) = 0 Then
        MsgBox "Cannot find Userid in " + ininame
    End If
    If Len(ini_str) > 0 Then
        userid = ini_str
    End If

    'Try to find the password in the ars ini file
    ini_str = fncParmGet(defstanza, "Password", ininame)
    'If it can't be found, check for an env var
    If Len(ini_str) = 0 Then
        MsgBox "Cannot find Password in " + ininame
    End If
    If Len(ini_str) > 0 Then
        pass = ini_str
    End If
    If pass = "<NULL>" Then
        pass = ""
    End If

    'Try to find the folder in the ars ini file
    ini_str = fncParmGet(defstanza, "Folder", ininame)
    folder = ini_str

End Sub
'This function returns information from the ini file.
Function fncParmGet(ByVal stanza As String, ByVal keyname As String, ByVal inifile As String)
    Dim Default, result As String
    Dim rc As Integer

    Default = ""
    result = Space$(255)

    rc = GetPrivateProfileString(stanza, keyname, Default, result, Len(result), inifile)
    If rc Then
        fncParmGet = Trim$(result)
        If Len(fncParmGet) > 1 Then
            fncParmGet = Left$(fncParmGet, Len(fncParmGet) - 1)
        End If
    Else
        fncParmGet = ""
    End If

End Function

'This function is only used to dummy up the date paid
'field of the form. The reason being is that for the
'demo, which uses the 'Baxter Bay Credit' folder,
'we cannot get this information from the database.
'This function adds approximately 20 days to the statement
'date field (which is passed in).
Public Function fncParseDate(ByVal stmtdate As String)
    Dim date_array(1 To 3) As String
    Dim searchch, workline, workchar As String
    Dim txtptr, lenstring, i As Integer
    Dim pay_day, pay_month, pay_year As Integer

    txtptr = 0
    searchch = Chr(47)
    workline = ""
    lenstring = Len(stmtdate)

'Extract chars to the first '/'
    For i = 1 To lenstring
        workchar = Mid$(stmtdate, i, 1)
        'When a '/' is found, store result, reset
        If workchar = searchch Then
            txtptr = txtptr + 1
            date_array(txtptr) = workline
            workline = ""
        'Otherwise, keep building the work string
        Else
            workline = workline + workchar
        End If
    Next

    If Len(workline) > 0 Then
        txtptr = txtptr + 1
        date_array(txtptr) = workline
    End If

'date_array contains three elements, the first is the month
    'number, the second is the day of the month and third is
    'the year. Simply check if the day of the month plus 20
    'is greater than 28, if so the difference becomes the new
    'day of the month and we increment the month number.
    pay_day = Int(date_array(2)) + 20
    pay_month = Int(date_array(1))
    pay_year = Int(date_array(3))
    If pay_day > 28 Then
        pay_day = pay_day - 28
        pay_month = pay_month + 1
        If pay_month > 12 Then
            pay_month = 1
            pay_year = pay_year + 1
        End If
    End If

    fncParseDate = LTrim(Str(pay_month)) + "/" + LTrim(Str(pay_day)) + "/" + LTrim(Str(pay_year))
End Function