ProformAPI

Discussions related to custom development with Select.
Post Reply
Shevy
Posts: 48
Joined: Tue Dec 23, 2008 12:21 pm

ProformAPI

Post by Shevy »

We have been using the ProformAPI on our website. We are now moving over to a more upgraded server Windwos Server 2008. I got the new version of the ProformAPI.dll. When I use it to pull information from proform I am running into 2 problems:
1) Since I need to set the size of the textbuilder before retrieveing the data, any extra space after the data is being filled with strange characters
2) When I try to replace the vbcrlf with a <br> to display in the browser it does not find vbcrlf.

Any help with this would be greatly appreciated.
Here is sample code:

Code: Select all


 Public Function getFieldValue(ByVal sFieldName As String, ByVal iSize As Integer, Optional ByVal bClose As Boolean = False) As String
        Dim value As String
        Dim sFieldValue As New System.Text.StringBuilder(iSize)
        APIWrapper.SPGetFieldValue(sFieldName, sFieldValue, iSize)
        value = sFieldValue.ToString
        getFieldValue = Regex.Replace(value, "[^A-Za-z0-9\s]+", "")
        If bClose Then
            APIWrapper.SPCloseFile()
        End If
    End Function
    Public Function openFile(ByVal sName As String, ByVal sFirmfile As String) As Integer
        openFile = APIWrapper.SPOpenFile("default", sFirmfile)
    End Function
End Class
Public Class APIWrapper
    Declare Ansi Function CreateProFormFile Lib "C:\Inetpub\wwwroot\TestAPI\bin\ProFormAPI.dll" _
       (ByVal csUserID As String, _
        ByVal chOptionalTemplateFilePath As String, _
        ByVal csPrefix As String, _
        ByVal csSuffix As String, _
        ByVal lType As Int32, _
        ByVal csFileNumbCode As String, _
        ByVal newFileID As System.Text.StringBuilder) As Integer

    Declare Ansi Function SPGetFieldValue Lib "C:\Inetpub\wwwroot\TestAPI\bin\ProFormAPI.dll" _
        (ByVal chFieldName As String, _
         ByVal chReturnValue As System.Text.StringBuilder, _
         ByVal nMaxSize As Integer) As Integer

    Declare Ansi Function SPSetFieldValue Lib "C:\Inetpub\wwwroot\TestAPI\bin\ProFormAPI.dll" _
         (ByVal chFieldName As String, _
         ByVal chFieldValue As String) As Integer

    Declare Ansi Function SPOpenFile Lib "C:\Inetpub\wwwroot\TestAPI\bin\ProFormAPI.dll" _
            (ByVal csUserID As String, ByVal csFileID As String) As Integer

    Declare Ansi Function SPSaveFile Lib "C:\Inetpub\wwwroot\TestAPI\bin\ProFormAPI.dll" () As Integer
    Declare Ansi Function SPCloseFile Lib "C:\Inetpub\wwwroot\TestAPI\bin\ProFormAPI.dll" () As Integer
End Class
'Here is a function call which returns the county name along with extra garbage characters.
Proform.getFieldValue("County", 50)
Stephen Martin
Posts: 2
Joined: Thu Oct 09, 2008 9:07 am

Re: ProformAPI

Post by Stephen Martin »

The ProFormAPI function SPGetFieldValue() returns the length of the data string returned.
Add an integer variable to catch the length of the value

Dim valueLen As Integer
. . .

valueLen = APIWrapper.SPGetFieldVlaue(sFieldName, sFieldValue, iSize)

then you can set your value string base on the valueLen returned by using StringBuilder's ToString substring function

value = sFieldValue.ToString(0,valueLen)
Shevy
Posts: 48
Joined: Tue Dec 23, 2008 12:21 pm

Re: ProformAPI

Post by Shevy »

That worked.
Thanks.
Post Reply