Thanks for the offer Vasu -- I'm working on a solution right now, and if it
doesn't work out, I might take you up on your kind offer.
Pete
-----Original Message-----
From: Vasu Vemuri [mailto:vasu@a...]
Sent: Monday, January 27, 2003 12:14 PM
To: professional vb
Subject: [pro_vb] RE: Request for help converting VB to C++
I have been a C Programmer for some time in my past and i admit that i
have very little experience of working with VC++.. but i think this code
reminds me of the File handling functions i did in C, which fscanf,
fprintf, fopen, feof etc. I think this should be done with relatively
little effort by anyone with average to good experience in C/C++. I can
try it if you want and if you can wait for a day or two...
vasu
-----Original Message-----
From: Pete Kipe [mailto:pkipe@c...]
Sent: Friday, January 24, 2003 11:37 PM
To: professional vb
Subject: [pro_vb] Request for help converting VB to C++
I've been helping others in this forum for nearly a year now, and now
I'm
in the unfortunate position of needing a big assist...
I have written the VB code to functionally duplicate a DLL for which I
am
not able to obtain source code. In terms of actual lines of code, the
entire thing is relatively small -- I'll paste it here for review:
'==================================================
Option Explicit
' Variables
Private mbInitialized As Boolean
Private mbValidRead As Boolean
Private miFile As Integer
Private msRecord As String
' Return codes
Private Const NO_ERROR As Long = 0
Private Const FILE_EOF As Long = 1
Private Const FILE_NOT_SUPPLIED As Long = 2
Private Const FILE_OPEN_ERROR As Long = 3
Private Const DESCRIPTION_TOO_SHORT As Long = 4
Private Const CODE_TOO_SHORT As Long = 5
' This is the only function in Clauseret. It opens the
' text file on first invocation, and returns the
' description and clause code for one record in the
' text file on every invocation. When all records
' have been read and returned, it returns a return
' code of 1, meaning end of file.
Public Function RetrieveClauseRec( _
ByVal ClauseList As String, _
ByRef Description As String, _
ByVal DescriptionLength As Long, _
ByRef Code As String, _
ByVal CodeLength As Long) As Long
' first time in,
If Not mbInitialized Then
' check for presence of file name
If ClauseList = "" Then
RetrieveClauseRec = FILE_NOT_SUPPLIED
Exit Function
End If
' open file
miFile = FreeFile()
On Error Resume Next
Open ClauseList For Input As miFile
If Err.Number <> 0 Then
RetrieveClauseRec = FILE_OPEN_ERROR
Exit Function
Else
mbInitialized = True
End If
On Error GoTo 0
End If
mbValidRead = False
Do While Not mbValidRead And mbInitialized
' read record
Line Input #miFile, msRecord
' if not end of file, process record
If Not EOF(miFile) Then
' input record has to be long enough to be valid
If Len(msRecord) >= 76 Then
' indicate that we have a non-empty record
mbValidRead = True
' caller's description field must be
' long enough to hold text
If DescriptionLength >= 63 Then
Description = Left(msRecord, 63)
' caller's code field must be
' long enough to hold code
If CodeLength >= 10 Then
Code = Mid(msRecord, 66, 10)
Else
RetrieveClauseRec = CODE_TOO_SHORT
End If
Else
RetrieveClauseRec = DESCRIPTION_TOO_SHORT
End If
End If
Else
RetrieveClauseRec = FILE_EOF
mbInitialized = False
End If
Loop
End Function
'=================================================
As I understand it, VB is not capable of generating a standard DLL, only
an ActiveX DLL. I have Visual Studio installed, therefore I have C++.
Would anyone consider helping me convert this thing to C++? I would be
sincerely grateful for any help...
Pete