Hi there. I have a vb.net function that converts a proprietary field type to a readable array. I am not sure if I should go the UFL route or if I should try to convert it into a crystal function. I am still using crystal 8.5. It seems as though the industry is moving away from UFL. Thoughts?
The vb.net function is below.
Public Function ParseDiaryField(ByVal fld As String) As String(,)
''' <summary>
''' The <code>ParseDiaryField</code> function is designed to parse out a Remedy Diary field object
''' The diary fields are separated by tab, space, and carriage return characters
''' The date format is also converted as the Remedy date format is epoch time so a conversion is used
''' <param name="args"></param>
''' <returns></returns>
'''
''' <see cref="link"/>
''' <seealso cref="link"/>
''' <list type="link"
''' Since:
''' Deprecated:
''' </summary>
Dim myArr(,) As String
Dim TAB_POS As Integer
Dim TAB_START As Integer
Dim TAB_LENGTH As Integer
Dim LF_POS As Integer
Dim LF_START As Integer
Dim LF_LENGTH As Integer
Dim CF_POS As Integer
Dim CF_START As Integer
Dim CF_LENGTH As Integer
Dim COUNT As Integer
Dim TOTLENGTH As Integer
Dim ExtractedDate As Double
TAB_POS = 0
TAB_START = 1
TAB_LENGTH = 1
LF_POS = 0
LF_START = 0
LF_LENGTH = 0
CF_POS = 0
CF_START = 0
CF_LENGTH = 0
COUNT = 1
TOTLENGTH = Len(fld)
While TAB_LENGTH < TOTLENGTH
ReDim Preserve myArr(3, COUNT)
'get position of carriage return
'THIS CHARACTER IS A TAB
'The tab is found after the time entry
TAB_POS = InStr(TAB_LENGTH, fld, "")
TAB_LENGTH = TAB_POS - TAB_START
LF_LENGTH = TAB_POS + 1
LF_START = TAB_POS + 1
LF_POS = InStr(LF_LENGTH, fld, "")
LF_LENGTH = LF_POS - LF_START
If LF_LENGTH < 0 Then LF_LENGTH = 0
CF_LENGTH = LF_POS + 1
CF_START = LF_POS + 1
'THIS CHARACTER IS A CARRIAGE RETURN
CF_POS = InStr(CF_LENGTH, fld, "")
If CF_POS = 0 Then
CF_LENGTH = TOTLENGTH - CF_START
Else
CF_LENGTH = CF_POS - CF_START
End If
ExtractedDate = Mid(fld, TAB_START, CDbl(TAB_LENGTH))
myArr(1, COUNT) = ConvertEpoch(ExtractedDate)
myArr(2, COUNT) = Mid(fld, LF_START, LF_LENGTH)
myArr(3, COUNT) = Mid(fld, CF_START, CF_LENGTH)
If CF_POS = 0 Then
TAB_LENGTH = TOTLENGTH
TAB_START = TOTLENGTH
COUNT = COUNT + 1
Else
TAB_LENGTH = CF_POS + 1
TAB_START = CF_POS + 1
COUNT = COUNT + 1
End If
End While
Return myArr
End Function
Jon Clayton
Senior Programmer Analyst
Montgomery, AL
The vb.net function is below.
Public Function ParseDiaryField(ByVal fld As String) As String(,)
''' <summary>
''' The <code>ParseDiaryField</code> function is designed to parse out a Remedy Diary field object
''' The diary fields are separated by tab, space, and carriage return characters
''' The date format is also converted as the Remedy date format is epoch time so a conversion is used
''' <param name="args"></param>
''' <returns></returns>
'''
''' <see cref="link"/>
''' <seealso cref="link"/>
''' <list type="link"
''' Since:
''' Deprecated:
''' </summary>
Dim myArr(,) As String
Dim TAB_POS As Integer
Dim TAB_START As Integer
Dim TAB_LENGTH As Integer
Dim LF_POS As Integer
Dim LF_START As Integer
Dim LF_LENGTH As Integer
Dim CF_POS As Integer
Dim CF_START As Integer
Dim CF_LENGTH As Integer
Dim COUNT As Integer
Dim TOTLENGTH As Integer
Dim ExtractedDate As Double
TAB_POS = 0
TAB_START = 1
TAB_LENGTH = 1
LF_POS = 0
LF_START = 0
LF_LENGTH = 0
CF_POS = 0
CF_START = 0
CF_LENGTH = 0
COUNT = 1
TOTLENGTH = Len(fld)
While TAB_LENGTH < TOTLENGTH
ReDim Preserve myArr(3, COUNT)
'get position of carriage return
'THIS CHARACTER IS A TAB
'The tab is found after the time entry
TAB_POS = InStr(TAB_LENGTH, fld, "")
TAB_LENGTH = TAB_POS - TAB_START
LF_LENGTH = TAB_POS + 1
LF_START = TAB_POS + 1
LF_POS = InStr(LF_LENGTH, fld, "")
LF_LENGTH = LF_POS - LF_START
If LF_LENGTH < 0 Then LF_LENGTH = 0
CF_LENGTH = LF_POS + 1
CF_START = LF_POS + 1
'THIS CHARACTER IS A CARRIAGE RETURN
CF_POS = InStr(CF_LENGTH, fld, "")
If CF_POS = 0 Then
CF_LENGTH = TOTLENGTH - CF_START
Else
CF_LENGTH = CF_POS - CF_START
End If
ExtractedDate = Mid(fld, TAB_START, CDbl(TAB_LENGTH))
myArr(1, COUNT) = ConvertEpoch(ExtractedDate)
myArr(2, COUNT) = Mid(fld, LF_START, LF_LENGTH)
myArr(3, COUNT) = Mid(fld, CF_START, CF_LENGTH)
If CF_POS = 0 Then
TAB_LENGTH = TOTLENGTH
TAB_START = TOTLENGTH
COUNT = COUNT + 1
Else
TAB_LENGTH = CF_POS + 1
TAB_START = CF_POS + 1
COUNT = COUNT + 1
End If
End While
Return myArr
End Function
Jon Clayton
Senior Programmer Analyst
Montgomery, AL