Odd Data Source

OSAdmin
Valued Contributor
Originally posted by Andrea Tout

7/10/2019

I have an odd data source if someone can help me. The Data Source works that the second to last column has the data, and the last column has a "cr" if it should be negative. So I wrote this complex expression:

 

Dim secondarCol As String = api.Parser.DelimitedParsedValues(8).Replace("$",String.Empty)
Dim primaryCol As String = api.Parser.DelimitedParsedValues(9).Replace(" ",String.Empty)

 

If primaryCol = "cr"
Return secondarCol.XFConvertToDecimal *-1
Else
Return secondarCol.XFConvertToDecimal
End If

This errors out, and I have tried a lot of different variations. However, if I pick the cr column to the left of the beginning balance (column 3) it works fine. so I figured out that, it only errors when you try to pull anything on the last column. This is because the file is tab delimited, an if there is no cr in the last column, there is not tab before the last column. This basically makes have of the file 10 columns and the other half 9 so I get an error that the index is out of range when I reference the last column. I know this is the problem but I can't seem to fix it! Does anyone have an idea how?

1 ACCEPTED SOLUTION

OSAdmin
Valued Contributor
Originally posted by Joakim Kulan

That was it! Here it the final product:
Dim secondarCol As String = api.Parser.DelimitedParsedValues(8).Replace(""$"",String.Empty)

 

If api.parser.delimitedparsedvalues.count > 9 Then
Return secondarCol.XFConvertToDecimal *-1
Else
Return secondarCol.XFConvertToDecimal
End If

View solution in original post

1 REPLY 1

OSAdmin
Valued Contributor
Originally posted by Joakim Kulan

That was it! Here it the final product:
Dim secondarCol As String = api.Parser.DelimitedParsedValues(8).Replace(""$"",String.Empty)

 

If api.parser.delimitedparsedvalues.count > 9 Then
Return secondarCol.XFConvertToDecimal *-1
Else
Return secondarCol.XFConvertToDecimal
End If