When I tries to create a
appeondotnetcomponent myComCaller
I am getting appeondotnetcomponent as illegal datatype. Please hep to how it will work
I am using PB 2017 R2
When I tries to create a
appeondotnetcomponent myComCaller
I am getting appeondotnetcomponent as illegal datatype. Please hep to how it will work
I am using PB 2017 R2
Thanks, for your awesome answer. I ran into another problem. I had my class and the dll is in the target folder. But when I tries to call the functions I am not able to get the result.
My .Net Class
Imports System.IO
Imports System.Text.RegularExpressions
Public Class TelsFileProcessor
Public Function GetNumRecordsSynchronous(ByVal filePath As String) As Integer
Dim numRecords As Integer = 0
Dim regex As New Regex("(\bNUMBER\b)(\s*)(=)(\s*)(')(\s*)(\d+)(\s*)(')")
Using reader As New StreamReader(filePath)
'count lines until we find [TRAILER]
Dim line As String = reader.ReadLine()
While Not line Is Nothing
If 0 = String.CompareOrdinal(line.Trim(), "[TRAILER]") Then
Exit While
End If
numRecords += 1
line = reader.ReadLine()
End While
'look for line with the following pattern: NUMBER = ' 12345 '
line = reader.ReadLine()
While Not line Is Nothing
Dim matches = regex.Matches(line)
If matches.Count = 1 Then
If Convert.ToInt32(matches(0).Groups.Item(7).Value) = numRecords Then
Return numRecords
Else
Return -1
End If
End If
line = reader.ReadLine()
End While
End Using
Return -1
End Function
Please help me in resolving the error.
Public Sub CopyRecordsSynchronous(ByVal srcFilePath As String, ByVal dstFilePath As String)
If File.Exists(dstFilePath) Then
File.Delete(dstFilePath)
End If
Dim recordCount As Integer = GetNumRecordsSynchronous(srcFilePath)
Using reader As New StreamReader(srcFilePath)
Using writer As New StreamWriter(dstFilePath)
For i As Integer = 1 To recordCount
Dim line = reader.ReadLine()
writer.WriteLine(line)
Next
End Using
End Using
End Sub
End Class
My Powerbuilder Code:
// Define Variables
long lRet
int iResult
string strError
appeondotnetcomponent comcaller
//create appeondotnetcomponent instance and set properties
comcaller = create appeondotnetcomponent
comcaller.componenttype = '1'
comcaller.typelib = 'Utility.dll'
comcaller.classdescript = 'TelsFileProcessor'
any paramlist[]
paramlist[1] = as_destination_file
paramlist[2] = as_insert_file
//invoke component method
lRet = comcaller.of_execinterface("CopyRecordsSynchronous" , paramlist)
if Integer(lRet) = 0 then
iResult = comcaller.ReturnValue
else
strError = comcaller.ErrorText
MessageBox("Error",strError)
end if
My file Copy is not working.
Did you get a chance to trace what is happening in your .NET component when its called via the "of_execinterface" method?
Regards ... Chris
My Code works with OLE one as below:
// Calling the .Net COM Component for File Copy
OLEObject fileProcessor
fileProcessor = CREATE OLEObject
fileProcessor.ConnectToNewObject("Utility.TelsFileProcessor")
lb_ret = fileProcessor.CopyRecordsSynchronous(this.is_samin_destination_files, this.is_samin_insert_files)
DESTROY fileProcessor