Translating datatype

Hello everyone...
I have a problem here..ill explain...

I have a column in my database which contains data about mainframe's datatypes.. like this...
pix x
pix xx
pix x(5)
pic 9
pic 9(4)


Thats how the data exists in the column.
Now I need to retrieve that data and convert them and store them into 2 columns in another database like this....This is the translated form of the example shown above...
DATA TYPE COLUMN    .  DATA LENGTH COLUMN
Alpha numeric             .  1
Alpha numeric             .  2
Alpha numeric             .  5
Numeric                      .  1
Numeric                      .  1

Im trying to make my program to do this...Can anyone help a bit?
Thanks
godwindotnetAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LordWabbitCommented:
Greetings

There are just so many ways to declare a variable in COBOL that what you are asking for is huge in scope.  However I have written some code to cater for your example, as well as a few more eg.
Pic X
Pic XX
Pic X(5)
Pic 9
Pic 9(4)
Pic 9(4)V(4)
Pic 9(14)V999

and the result

Alpha Numeric : 1
Alpha Numeric : 2
Alpha Numeric : 5
Numeric : 1
Numeric : 4
Numeric : 4.4
Numeric : 14.3

For debugging etc. I used two list boxes, source and result, modify this as you see fit.  Be aware though that if you encounter a data type definition which does not fit into the above examples to some degree or other that the code will probably break.  You will then need to alter the code to cater for the new variation (as well as ensuring that it does not break for previously working data types.  You also might want to add a check for a . (period) used in display fields etc.  Like I said it's not a small thing u are asking for.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For intIdx As Integer = 0 To lstSource.Items.Count - 1
            Dim strType As String = "Numeric"
            Dim dblLength As Double
            Dim strSource As String = lstSource.Items(intIdx).ToString.ToLower.Replace("pic", "").Trim
            If strSource.Substring(0, 1) = "x" Then
                strType = "Alpha Numeric"
            End If
            Dim intStart As Integer = strSource.IndexOf("(")
            Dim intEnd As Integer
            If intStart > -1 Then intEnd = strSource.IndexOf(")", intStart)
            If intStart > 0 And intEnd > 0 Then
                dblLength = strSource.Substring(intStart + 1, intEnd - intStart - 1)
            Else
                dblLength = strSource.Length
            End If
            If strSource.Contains("v") Then
                Dim intRem As Integer = strSource.IndexOf("v")
                intStart = strSource.IndexOf("(", intRem)
                intEnd = strSource.IndexOf(")", intRem)
                Dim strRem As String
                If intStart > 0 And intEnd > 0 Then
                    strRem = strSource.Substring(intStart + 1, intEnd - intStart - 1)
                    dblLength += intRem / (10 * strRem.Length)
                Else
                    strRem = strSource.Length - intRem - 1
                    dblLength += strRem / (10 * strRem.Length)
                End If
            End If
            lstResult.Items.Add(strType & " : " & dblLength)
        Next
    End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LordWabbitCommented:
Tried a pic 999v999 and it came back with 7.3, you will need to put some extra code to check for v or . in the else where
dblLength = strSource.Length

I hope for your sake that there are no display type datatypes in that table, things could get really hairy then.
godwindotnetAuthor Commented:
Can you please modify that one to work with the v and stuff?
Thanks
LordWabbitCommented:
There is still no guarentee it will work with all definitions, if you encounter one which gives you problems or incorrect values let me know.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For intIdx As Integer = 0 To lstSource.Items.Count - 1
            Dim strType As String = "Numeric"
            Dim dblLength As Double
            Dim strSource As String = lstSource.Items(intIdx).ToString.ToLower.Replace("pic", "").Trim
            If strSource.Substring(0, 1) = "x" Then
                strType = "Alpha Numeric"
            End If
            Dim intStart As Integer = strSource.IndexOf("(")
            Dim intEnd As Integer
            If intStart > -1 Then intEnd = strSource.IndexOf(")", intStart)
            If intStart > 0 And intEnd > 0 Then
                dblLength = strSource.Substring(intStart + 1, intEnd - intStart - 1)
            Else
                If strSource.Contains("v") Then
                    Dim intRem As Integer = strSource.IndexOf("v")
                    dblLength = strSource.Length - intRem - 1
                Else
                    dblLength = strSource.Length
                End If
            End If
            If strSource.Contains("v") Then
                Dim intRem As Integer = strSource.IndexOf("v")
                intStart = strSource.IndexOf("(", intRem)
                intEnd = strSource.IndexOf(")", intRem)
                Dim strRem As String
                If intStart > 0 And intEnd > 0 Then
                    strRem = strSource.Substring(intStart + 1, intEnd - intStart - 1)
                    dblLength += intRem / (10 * strRem.Length)
                Else
                    strRem = strSource.Length - intRem - 1
                    dblLength += strRem / (10 * strRem.Length)
                End If
            End If
            lstResult.Items.Add(strType & " : " & dblLength)
        Next
    End Sub
godwindotnetAuthor Commented:
Awesomeeee :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.