ZH's software thread

Place to talk about all that new hardware and decaying software you have.

Moderator: General Mods

Post Reply
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

funkyass wrote:carry bit.
The overflow bit reeks of awesomness too.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
ZH/Franky

Post by ZH/Franky »

Hmm, thanks for the advice grin (and funkyass), I'll look into it soon (well, I was going to look into making my own data types soon anyway, so as the saying goes, "speak of the devil", right?).

Oh, and by the way, I've finished my ISBN program. It now does the following:
1) convert (either way) between ISBN10 and ISBN13
2) (as it has done before anyway) check the validity of either an ISBN10 or ISBN13 number

I also added a "shameless plug".

Since I've finished it, it now deserves a name. I shall call it "Z-130".

Code: Select all

Option Strict On
Option Explicit On
Module Module1

    Dim sISBN13 As String = ""
    Dim sISBN10 As String = ""

    Function bVerifySum13(ByRef usISBN13 As String) As Boolean
        Dim iMax, iSum As Integer
        bVerifySum13 = True
        iMax = 0
        If usISBN13 Like "#############" Then
            For j As Integer = 2 To 12 Step 2
                iMax += ((Convert.ToInt32(Mid(usISBN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(usISBN13, j, 1)))))
            Next
            iSum = (10 - (iMax Mod 10)) Mod 10
            If iSum <> Convert.ToInt32(Mid(usISBN13, 13, 1)) Then
                bVerifySum13 = False
            End If
        Else
            bVerifySum13 = False
        End If
    End Function

    Function bVerifySum10(ByRef usISBN10 As String) As Boolean
        Dim iMax As Integer = 0
        bVerifySum10 = True
        If usISBN10 Like "##########" Or usISBN10.Length = 10 And Mid(usISBN10, 1, 9) Like "#########" And Mid(usISBN10, 10, 1) = "x" Then
            For j = 10 To 2 Step -1
                iMax += ((Convert.ToInt32(Mid(usISBN10, (10 - (j - 1)), 1))) * j)
            Next
            If Mid(usISBN10, 10, 1) <> "x" Then
                iMax += Convert.ToInt32(Mid(usISBN10, 10, 1))
            Else
                iMax += 10
            End If
            If (iMax Mod 11) <> 0 Then
                bVerifySum10 = False
            End If
        Else
            bVerifySum10 = False
        End If
    End Function

    Function sConvertN10toN13(ByRef usISBN10 As String) As String
        Dim iMax As Integer = 0
        sConvertN10toN13 = "978" + Mid(usISBN10, 1, 9)
        For j As Integer = 2 To 12 Step 2
            iMax += (Convert.ToInt32(Mid(sConvertN10toN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(sConvertN10toN13, j, 1))))
        Next
        sConvertN10toN13 += ((10 - (iMax Mod 10)) Mod 10).ToString
    End Function

    Function sConvertN13toN10(ByRef usISBN13 As String) As String
        Dim iMax As Integer = 0
        Dim iCount As Integer = 0
        sConvertN13toN10 = Mid(usISBN13, 4, 9)
        For j As Integer = 10 To 2 Step -1
            iMax += ((Convert.ToInt32(Mid(sConvertN13toN10, (10 - (j - 1)), 1))) * j)
        Next
        Do
            iCount += 1
        Loop Until ((iMax + iCount) Mod 11) = 0
        sConvertN13toN10 += iCount.ToString
    End Function

    Sub Main()
        Dim sInputChoice As String = ""
        Call shameless_plug()
        Call DisplayOptions()
        Do
            Call Console.Write("?: ")
            sInputChoice = Console.ReadLine()
            Select Case sInputChoice
                Case "quit"
                    End
                Case "disp"
                    Call DisplayOptions()
                Case "10"
                    Call InterfaceISBN10()
                Case "13"
                    Call InterfaceISBN13()
                Case "10to13"
                    Call InterfaceISBN10ToISBN13()
                Case "13to10"
                    Call InterfaceISBN13ToISBN10()
                Case Else
                    Call Console.WriteLine("Invalid option")
            End Select
        Loop
    End Sub

    Sub InterfaceISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-10 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN10 = "r"
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid ISBN-10 number")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("Valid ISBN-10 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-13 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN13 = "r"
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid ISBN-13 number")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("Valid ISBN-13 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN10ToISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("As an ISBN13 number, this is " + sConvertN10toN13(sISBN10))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN13 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum13(sConvertN10toN13(sISBN10)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN10 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13ToISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("As an ISBN10 number, this is " + sConvertN13toN10(sISBN13))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN10 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum10(sConvertN13toN10(sISBN13)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN13 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub DisplayOptions()
        Call Console.WriteLine("Options:")
        Call Console.WriteLine("10 - ISBN10 validation")
        Call Console.WriteLine("13 - ISBN13 validation")
        Call Console.WriteLine("10to13 - ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("13to10 - ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("disp - display these options")
        Call Console.WriteLine("quit - exit this program")
    End Sub

    Sub shameless_plug()
        Call Console.WriteLine("Z-130 version pi")
        Call Console.WriteLine("Written by Zero-Hero")
        Call Console.WriteLine("License: Public Domain")
        Call Console.WriteLine()
        Call Console.WriteLine("This program does the following:")
        Call Console.WriteLine("1) Convert (either way) between ISBN10 and ISBN13, at your choice")
        Call Console.WriteLine("2) Check the validity of either an ISBN10 or ISBN13 number, at your choice")
        Call Console.WriteLine()
        Call Console.WriteLine("This program will NOT do the following:")
        Call Console.WriteLine("1) Make girls like you")
        Call Console.WriteLine("2) Make men like you")
        Call Console.WriteLine()
        Call Console.Write("Press enter to continue")
        Call Console.ReadLine()
        Call Console.WriteLine()
    End Sub

End Module
If you guys see any bugs and/or things that need improving, let me know.
Last edited by ZH/Franky on Mon Dec 01, 2008 11:51 pm, edited 1 time in total.
ZH/Franky

Post by ZH/Franky »

Ok, ignore my previous code. There was a bug in that during ISBN13 to ISBN10 conversion, if the calculated check digit of the ISBN10 number was 10 or 11, it would not be recorded (respectively) as X or 0. This has now been fixed.

So, here's the new code:

Code: Select all

Option Strict On
Option Explicit On
Module Module1

    Dim sISBN13 As String = ""
    Dim sISBN10 As String = ""

    Function bVerifySum13(ByRef usISBN13 As String) As Boolean
        Dim iMax, iSum As Integer
        bVerifySum13 = True
        iMax = 0
        If usISBN13 Like "#############" Then
            For j As Integer = 2 To 12 Step 2
                iMax += ((Convert.ToInt32(Mid(usISBN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(usISBN13, j, 1)))))
            Next
            iSum = (10 - (iMax Mod 10)) Mod 10
            If iSum <> Convert.ToInt32(Mid(usISBN13, 13, 1)) Then
                bVerifySum13 = False
            End If
        Else
            bVerifySum13 = False
        End If
    End Function

    Function bVerifySum10(ByRef usISBN10 As String) As Boolean
        Dim iMax As Integer = 0
        bVerifySum10 = True
        If usISBN10 Like "##########" Or usISBN10.Length = 10 And Mid(usISBN10, 1, 9) Like "#########" And Mid(usISBN10, 10, 1) = "x" Then
            For j = 10 To 2 Step -1
                iMax += ((Convert.ToInt32(Mid(usISBN10, (10 - (j - 1)), 1))) * j)
            Next
            If Mid(usISBN10, 10, 1) <> "x" Then
                iMax += Convert.ToInt32(Mid(usISBN10, 10, 1))
            Else
                iMax += 10
            End If
            If (iMax Mod 11) <> 0 Then
                bVerifySum10 = False
            End If
        Else
            bVerifySum10 = False
        End If
    End Function

    Function sConvertN10toN13(ByRef usISBN10 As String) As String
        Dim iMax As Integer = 0
        sConvertN10toN13 = "978" + Mid(usISBN10, 1, 9)
        For j As Integer = 2 To 12 Step 2
            iMax += (Convert.ToInt32(Mid(sConvertN10toN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(sConvertN10toN13, j, 1))))
        Next
        sConvertN10toN13 += ((10 - (iMax Mod 10)) Mod 10).ToString
    End Function

    Function sConvertN13toN10(ByRef usISBN13 As String) As String
        Dim iMax As Integer = 0
        Dim iCount As Integer = 0
        sConvertN13toN10 = Mid(usISBN13, 4, 9)
        For j As Integer = 10 To 2 Step -1
            iMax += ((Convert.ToInt32(Mid(sConvertN13toN10, (10 - (j - 1)), 1))) * j)
        Next
        If (iMax Mod 11) <> 0 Then
            Do
                iCount += 1
            Loop Until ((iMax + iCount) Mod 11) = 0
        End If
        If iCount = 10 Then
            sConvertN13toN10 += "x"
        ElseIf iCount = 11 Then
            sConvertN13toN10 += "0"
        Else
            sConvertN13toN10 += iCount.ToString
        End If
    End Function

    Sub Main()
        Dim sInputChoice As String = ""
        Call shameless_plug()
        Call DisplayOptions()
        Do
            Call Console.Write("?: ")
            sInputChoice = Console.ReadLine()
            Select Case sInputChoice
                Case "quit"
                    End
                Case "disp"
                    Call DisplayOptions()
                Case "10"
                    Call InterfaceISBN10()
                Case "13"
                    Call InterfaceISBN13()
                Case "10to13"
                    Call InterfaceISBN10ToISBN13()
                Case "13to10"
                    Call InterfaceISBN13ToISBN10()
                Case Else
                    Call Console.WriteLine("Invalid option")
            End Select
        Loop
    End Sub

    Sub InterfaceISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-10 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN10 = "r"
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid ISBN-10 number")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("Valid ISBN-10 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-13 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN13 = "r"
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid ISBN-13 number")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("Valid ISBN-13 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN10ToISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("As an ISBN13 number, this is " + sConvertN10toN13(sISBN10))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN13 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum13(sConvertN10toN13(sISBN10)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN10 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13ToISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("As an ISBN10 number, this is " + sConvertN13toN10(sISBN13))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN10 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum10(sConvertN13toN10(sISBN13)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN13 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub DisplayOptions()
        Call Console.WriteLine("Options:")
        Call Console.WriteLine("10 - ISBN10 validation")
        Call Console.WriteLine("13 - ISBN13 validation")
        Call Console.WriteLine("10to13 - ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("13to10 - ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("disp - display these options")
        Call Console.WriteLine("quit - exit this program")
    End Sub

    Sub shameless_plug()
        Call Console.WriteLine("Z-130 version pi")
        Call Console.WriteLine("Written by Zero-Hero")
        Call Console.WriteLine("License: Public Domain")
        Call Console.WriteLine()
        Call Console.WriteLine("This program does the following:")
        Call Console.WriteLine("1) Convert (either way) between ISBN10 and ISBN13, at your choice")
        Call Console.WriteLine("2) Check the validity of either an ISBN10 or ISBN13 number, at your choice")
        Call Console.WriteLine()
        Call Console.WriteLine("This program will NOT do the following:")
        Call Console.WriteLine("1) Make girls like you")
        Call Console.WriteLine("2) Make men like you")
        Call Console.WriteLine()
        Call Console.Write("Press enter to continue")
        Call Console.ReadLine()
        Call Console.WriteLine()
    End Sub

End Module

EDIT: Some more minor bugs fixed. As far as I can tell, my code is now 100% perfect and free of bugs:

Code: Select all

Option Strict On
Option Explicit On
Module Module1

    Dim sISBN13 As String = ""
    Dim sISBN10 As String = ""

    Function bVerifySum13(ByRef usISBN13 As String) As Boolean
        Dim iMax, iSum As Integer
        bVerifySum13 = True
        iMax = 0
        If usISBN13 Like "#############" Then
            For j As Integer = 2 To 12 Step 2
                iMax += ((Convert.ToInt32(Mid(usISBN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(usISBN13, j, 1)))))
            Next
            iSum = (10 - (iMax Mod 10)) Mod 10
            If iSum <> Convert.ToInt32(Mid(usISBN13, 13, 1)) Then
                bVerifySum13 = False
            End If
        Else
            bVerifySum13 = False
        End If
    End Function

    Function bVerifySum10(ByRef usISBN10 As String) As Boolean
        Dim iMax As Integer = 0
        bVerifySum10 = True
        If usISBN10 Like "##########" Or usISBN10.Length = 10 And Mid(usISBN10, 1, 9) Like "#########" And Mid(usISBN10, 10, 1) = "x" Then
            For j = 10 To 2 Step -1
                iMax += ((Convert.ToInt32(Mid(usISBN10, (10 - (j - 1)), 1))) * j)
            Next
            If Mid(usISBN10, 10, 1) <> "x" Then
                iMax += Convert.ToInt32(Mid(usISBN10, 10, 1))
            Else
                iMax += 10
            End If
            If (iMax Mod 11) <> 0 Then
                bVerifySum10 = False
            End If
        Else
            bVerifySum10 = False
        End If
    End Function

    Function sConvertN10toN13(ByRef usISBN10 As String) As String
        Dim iMax As Integer = 0
        sConvertN10toN13 = "978" + Mid(usISBN10, 1, 9)
        For j As Integer = 2 To 12 Step 2
            iMax += (Convert.ToInt32(Mid(sConvertN10toN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(sConvertN10toN13, j, 1))))
        Next
        sConvertN10toN13 += ((10 - (iMax Mod 10)) Mod 10).ToString
    End Function

    Function sConvertN13toN10(ByRef usISBN13 As String) As String
        Dim iMax As Integer = 0
        Dim iCount As Integer = 0
        sConvertN13toN10 = Mid(usISBN13, 4, 9)
        For j As Integer = 10 To 2 Step -1
            iMax += ((Convert.ToInt32(Mid(sConvertN13toN10, (10 - (j - 1)), 1))) * j)
        Next
        If (iMax Mod 11) <> 0 Then
            Do
                iCount += 1
            Loop Until ((iMax + iCount) Mod 11) = 0
            If iCount = 10 Then
                sConvertN13toN10 += "x"
            Else
                sConvertN13toN10 += iCount.ToString
            End If
        Else
            sConvertN13toN10 += "0"
        End If
    End Function

    Sub Main()
        Dim sInputChoice As String = ""
        Call shameless_plug()
        Call DisplayOptions()
        Do
            Call Console.Write("?: ")
            sInputChoice = Console.ReadLine()
            Select Case sInputChoice
                Case "quit"
                    End
                Case "disp"
                    Call DisplayOptions()
                Case "10"
                    Call InterfaceISBN10()
                Case "13"
                    Call InterfaceISBN13()
                Case "10to13"
                    Call InterfaceISBN10ToISBN13()
                Case "13to10"
                    Call InterfaceISBN13ToISBN10()
                Case Else
                    Call Console.WriteLine("Invalid option")
            End Select
        Loop
    End Sub

    Sub InterfaceISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-10 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN10 = "r"
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid ISBN-10 number")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("Valid ISBN-10 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-13 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN13 = "r"
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid ISBN-13 number")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("Valid ISBN-13 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN10ToISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("As an ISBN13 number, this is " + sConvertN10toN13(sISBN10))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN13 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum13(sConvertN10toN13(sISBN10)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN10 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13ToISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("As an ISBN10 number, this is " + sConvertN13toN10(sISBN13))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN10 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum10(sConvertN13toN10(sISBN13)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN13 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub DisplayOptions()
        Call Console.WriteLine("Options:")
        Call Console.WriteLine("10 - ISBN10 validation")
        Call Console.WriteLine("13 - ISBN13 validation")
        Call Console.WriteLine("10to13 - ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("13to10 - ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("disp - display these options")
        Call Console.WriteLine("quit - exit this program")
    End Sub

    Sub shameless_plug()
        Call Console.WriteLine("Z-130 version pi")
        Call Console.WriteLine("Written by Zero-Hero")
        Call Console.WriteLine("License: Public Domain")
        Call Console.WriteLine()
        Call Console.WriteLine("This program does the following:")
        Call Console.WriteLine("1) Convert (either way) between ISBN10 and ISBN13, at your choice")
        Call Console.WriteLine("2) Check the validity of either an ISBN10 or ISBN13 number, at your choice")
        Call Console.WriteLine()
        Call Console.WriteLine("This program will NOT do the following:")
        Call Console.WriteLine("1) Make girls like you")
        Call Console.WriteLine("2) Make men like you")
        Call Console.WriteLine()
        Call Console.Write("Press enter to continue")
        Call Console.ReadLine()
        Call Console.WriteLine()
    End Sub

End Module
EDIT:
I've changed my mind; I've just found out that "z130" is the name of a particular Samsung cellphone, and I don't want to infringe upon any trademarks, so I'll call my program "AK3N" instead.

Code: Select all

Option Strict On
Option Explicit On
Module Module1

    Dim sISBN13 As String = ""
    Dim sISBN10 As String = ""

    Function bVerifySum13(ByRef usISBN13 As String) As Boolean
        Dim iMax, iSum As Integer
        bVerifySum13 = True
        iMax = 0
        If usISBN13 Like "#############" Then
            For j As Integer = 2 To 12 Step 2
                iMax += ((Convert.ToInt32(Mid(usISBN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(usISBN13, j, 1)))))
            Next
            iSum = (10 - (iMax Mod 10)) Mod 10
            If iSum <> Convert.ToInt32(Mid(usISBN13, 13, 1)) Then
                bVerifySum13 = False
            End If
        Else
            bVerifySum13 = False
        End If
    End Function

    Function bVerifySum10(ByRef usISBN10 As String) As Boolean
        Dim iMax As Integer = 0
        bVerifySum10 = True
        If usISBN10 Like "##########" Or usISBN10.Length = 10 And Mid(usISBN10, 1, 9) Like "#########" And Mid(usISBN10, 10, 1) = "x" Then
            For j = 10 To 2 Step -1
                iMax += ((Convert.ToInt32(Mid(usISBN10, (10 - (j - 1)), 1))) * j)
            Next
            If Mid(usISBN10, 10, 1) <> "x" Then
                iMax += Convert.ToInt32(Mid(usISBN10, 10, 1))
            Else
                iMax += 10
            End If
            If (iMax Mod 11) <> 0 Then
                bVerifySum10 = False
            End If
        Else
            bVerifySum10 = False
        End If
    End Function

    Function sConvertN10toN13(ByRef usISBN10 As String) As String
        Dim iMax As Integer = 0
        sConvertN10toN13 = "978" + Mid(usISBN10, 1, 9)
        For j As Integer = 2 To 12 Step 2
            iMax += (Convert.ToInt32(Mid(sConvertN10toN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(sConvertN10toN13, j, 1))))
        Next
        sConvertN10toN13 += ((10 - (iMax Mod 10)) Mod 10).ToString
    End Function

    Function sConvertN13toN10(ByRef usISBN13 As String) As String
        Dim iMax As Integer = 0
        Dim iCount As Integer = 0
        sConvertN13toN10 = Mid(usISBN13, 4, 9)
        For j As Integer = 10 To 2 Step -1
            iMax += ((Convert.ToInt32(Mid(sConvertN13toN10, (10 - (j - 1)), 1))) * j)
        Next
        If (iMax Mod 11) <> 0 Then
            Do
                iCount += 1
            Loop Until ((iMax + iCount) Mod 11) = 0
            If iCount = 10 Then
                sConvertN13toN10 += "x"
            Else
                sConvertN13toN10 += iCount.ToString
            End If
        Else
            sConvertN13toN10 += "0"
        End If
    End Function

    Sub Main()
        Dim sInputChoice As String = ""
        Call shameless_plug()
        Call DisplayOptions()
        Do
            Call Console.Write("?: ")
            sInputChoice = Console.ReadLine()
            Select Case sInputChoice
                Case "quit"
                    End
                Case "disp"
                    Call DisplayOptions()
                Case "10"
                    Call InterfaceISBN10()
                Case "13"
                    Call InterfaceISBN13()
                Case "10to13"
                    Call InterfaceISBN10ToISBN13()
                Case "13to10"
                    Call InterfaceISBN13ToISBN10()
                Case Else
                    Call Console.WriteLine("Invalid option")
            End Select
        Loop
    End Sub

    Sub InterfaceISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-10 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN10 = "r"
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid ISBN-10 number")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("Valid ISBN-10 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-13 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do Until sISBN13 = "r"
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid ISBN-13 number")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("Valid ISBN-13 number")
            End If
        Loop
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN10ToISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine()
            sISBN10 = sISBN10.ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("As an ISBN13 number, this is " + sConvertN10toN13(sISBN10))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN13 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum13(sConvertN10toN13(sISBN10)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN10 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13ToISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine()
            sISBN13 = sISBN13.ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid input")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("As an ISBN10 number, this is " + sConvertN13toN10(sISBN13))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN10 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum10(sConvertN13toN10(sISBN13)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN13 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub DisplayOptions()
        Call Console.WriteLine("Options:")
        Call Console.WriteLine("10 - ISBN10 validation")
        Call Console.WriteLine("13 - ISBN13 validation")
        Call Console.WriteLine("10to13 - ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("13to10 - ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("disp - display these options")
        Call Console.WriteLine("quit - exit this program")
    End Sub

    Sub shameless_plug()
        Call Console.WriteLine("AK3N version pi")
        Call Console.WriteLine("Written by Zero-Hero")
        Call Console.WriteLine("License: Public Domain")
        Call Console.WriteLine()
        Call Console.WriteLine("This program does the following:")
        Call Console.WriteLine("1) Convert (either way) between ISBN10 and ISBN13, at your choice")
        Call Console.WriteLine("2) Check the validity of either an ISBN10 or ISBN13 number, at your choice")
        Call Console.WriteLine()
        Call Console.WriteLine("This program will NOT do the following:")
        Call Console.WriteLine("1) Make girls like you")
        Call Console.WriteLine("2) Make men like you")
        Call Console.WriteLine()
        Call Console.Write("Press enter to continue")
        Call Console.ReadLine()
        Call Console.WriteLine()
    End Sub

End Module
ZH/Franky

Post by ZH/Franky »

Added a few more validation checks, for the sake of being thorough:

Code: Select all

Option Strict On
Option Explicit On
Module Module1

    Dim sISBN13 As String = ""
    Dim sISBN10 As String = ""

    Function bVerifySum13(ByRef usISBN13 As String) As Boolean
        Dim iMax As Integer = 0
        bVerifySum13 = True
        If usISBN13 Like "#############" Then
            For j As Integer = 2 To 12 Step 2
                iMax += ((Convert.ToInt32(Mid(usISBN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(usISBN13, j, 1)))))
            Next
            If ((10 - (iMax Mod 10)) Mod 10) <> Convert.ToInt32(Mid(usISBN13, 13, 1)) Then
                bVerifySum13 = False
            End If
        Else
            bVerifySum13 = False
        End If
    End Function

    Function sConvertN13toN10(ByRef usISBN13 As String) As String
        Dim iMax As Integer = 0
        Dim iCount As Integer = 0
        sConvertN13toN10 = Mid(usISBN13, 4, 9)
        For j As Integer = 10 To 2 Step -1
            iMax += ((Convert.ToInt32(Mid(sConvertN13toN10, (10 - (j - 1)), 1))) * j)
        Next
        If (iMax Mod 11) <> 0 Then
            Do
                iCount += 1
            Loop Until ((iMax + iCount) Mod 11) = 0
            If iCount = 10 Then
                sConvertN13toN10 += "x"
            Else
                sConvertN13toN10 += iCount.ToString
            End If
        Else
            sConvertN13toN10 += "0"
        End If
    End Function

    Function bVerifySum10(ByRef usISBN10 As String) As Boolean
        Dim iMax As Integer = 0
        bVerifySum10 = True
        If usISBN10 Like "##########" Or usISBN10.Length = 10 And Mid(usISBN10, 1, 9) Like "#########" And Mid(usISBN10, 10, 1) = "x" Then
            For j = 10 To 2 Step -1
                iMax += ((Convert.ToInt32(Mid(usISBN10, (10 - (j - 1)), 1))) * j)
            Next
            If Mid(usISBN10, 10, 1) <> "x" Then
                iMax += Convert.ToInt32(Mid(usISBN10, 10, 1))
            Else
                iMax += 10
            End If
            If (iMax Mod 11) <> 0 Then
                bVerifySum10 = False
            End If
        Else
            bVerifySum10 = False
        End If
    End Function

    Function sConvertN10toN13(ByRef usISBN10 As String) As String
        Dim iMax As Integer = 0
        sConvertN10toN13 = "978" + Mid(usISBN10, 1, 9)
        For j As Integer = 2 To 12 Step 2
            iMax += (Convert.ToInt32(Mid(sConvertN10toN13, (j - 1), 1))) + (3 * (Convert.ToInt32(Mid(sConvertN10toN13, j, 1))))
        Next
        sConvertN10toN13 += ((10 - (iMax Mod 10)) Mod 10).ToString
    End Function

    Sub InterfaceISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-10 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine().ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid ISBN-10 number")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("Valid ISBN-10 number")
            End If
        Loop Until sISBN10 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN-13 Validation")
        Call Console.WriteLine("(To exit back to main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine().ToLower
            If sISBN13 <> "r" And Mid(sISBN13, 1, 3) <> "978" And Mid(sISBN13, 1, 3) <> "979" Then
                Call Console.WriteLine("Invalid input; prefix must be 978 or 979")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid ISBN-13 number")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("Valid ISBN-13 number")
            End If


        Loop Until sISBN13 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN10ToISBN13()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?10: ")
            sISBN10 = Console.ReadLine().ToLower
            If sISBN10 <> "r" And bVerifySum10(sISBN10) <> True Then
                Call Console.WriteLine("Invalid ISBN-10 number")
            ElseIf sISBN10 <> "r" And bVerifySum10(sISBN10) = True Then
                Call Console.WriteLine("As an ISBN13 number, this is " + sConvertN10toN13(sISBN10))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN13 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum13(sConvertN10toN13(sISBN10)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN10 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub InterfaceISBN13ToISBN10()
        Call Console.WriteLine()
        Call Console.WriteLine("ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("(To exit back to the main menu, type 'r' and hit return)")
        Do
            Call Console.Write("?13: ")
            sISBN13 = Console.ReadLine().ToLower
            If sISBN13 <> "r" And bVerifySum13(sISBN13) <> True Then
                Call Console.WriteLine("Invalid ISBN-13 number")
            ElseIf sISBN13 <> "r" And Mid(sISBN13, 1, 3) <> "978" And Mid(sISBN13, 1, 3) <> "979" Then
                Call Console.WriteLine("Invalid input; prefix must be 978 or 979")
            ElseIf sISBN13 <> "r" And Mid(sISBN13, 1, 3) = "979" Then
                Call Console.WriteLine("The inputted ISBN13 number itself is valid, but")
                Call Console.WriteLine("ISBN13 numbers prefixed with 979")
                Call Console.WriteLine("cannot be converted to ISBN10")
            ElseIf sISBN13 <> "r" And bVerifySum13(sISBN13) = True Then
                Call Console.WriteLine("As an ISBN10 number, this is " + sConvertN13toN10(sISBN13))
                Call System.Threading.Thread.Sleep(1200)
                Call Console.WriteLine("Verification of newly converted ISBN10 number...")
                Call System.Threading.Thread.Sleep(300)
                If bVerifySum10(sConvertN13toN10(sISBN13)) <> True Then
                    Call Console.WriteLine("Oops, it seems that this is invalid")
                Else
                    Call Console.WriteLine("Everything A-OK")
                End If
            End If
        Loop Until sISBN13 = "r"
        Call Console.WriteLine()
        Call DisplayOptions()
    End Sub

    Sub DisplayOptions()
        Call Console.WriteLine("Options:")
        Call Console.WriteLine("10 - ISBN10 validation")
        Call Console.WriteLine("13 - ISBN13 validation")
        Call Console.WriteLine("10to13 - ISBN10 to ISBN13 conversion")
        Call Console.WriteLine("13to10 - ISBN13 to ISBN10 conversion")
        Call Console.WriteLine("disp - display these options")
        Call Console.WriteLine("quit - exit this program")
    End Sub

    Sub Main()
        Dim sInputChoice As String = ""
        Call Console.WriteLine("AK3N: ISBN 10/13 Validation and Conversion")
        Call Console.WriteLine("License: Public Domain")
        Call Console.WriteLine("Written by Zero-Hero")
        Call Console.WriteLine()
        Call DisplayOptions()
        Call Console.WriteLine()
        Do
            Call Console.Write("?: ")
            sInputChoice = Console.ReadLine().ToLower
            Select Case sInputChoice
                Case "quit"
                    End
                Case "disp"
                    Call DisplayOptions()
                Case "10"
                    Call InterfaceISBN10()
                Case "13"
                    Call InterfaceISBN13()
                Case "10to13"
                    Call InterfaceISBN10ToISBN13()
                Case "13to10"
                    Call InterfaceISBN13ToISBN10()
                Case Else
                    Call Console.WriteLine("Invalid option")
            End Select
        Loop
    End Sub

End Module
Aside from the lack of a GUI, this now rivals the quality of the ISBN 10/13 validator/converter provided on the official isbn website (found at http://www.isbn.org/converterpub.asp).
Now, all I need to do is learn how to do a GUI in vb.net, and I'm good (though it will be purely for fun, since we don't do any GUI applications in VB.Net in the first year of the course I'm taking at college).
Though, I don't want to use the Windows Forms templates, so I'll be looking around on the web to try and learn how to write a windows forms application manually, with my own hand.

Also, I'll be getting into C# soon. I'm currently downloading a DVD image from MS's site that has the following:
- VB.NET 2008 Express (yah, I'm downloading it again just so I can have the iso with all the other .Net compilers too. Meh)
- Visual Web Developer 2008 (most probably won't need, but meh)
- Visual C# 2008 Express
- Visual C++ 2008 Express
- SQL Server 2008 Express (?? most probably won't need this, but again, meh)
- MSDN Express Library (?? whatever the hell that is. I'll have to google it sometime).
Ever since I've got into programming at college, I've gotten a lot further in terms of learning things. Beforehand, I had very little support, and it was very hard to get into. I'll be getting into C# so I can get familiar with a C-like language (but with the tremendous support that the .Net programming ide's provide), (even though it's not really C, and uses similar syntax but is a different language). Hopefully, I can really get into writing good code in pure C in a few months time. That's my current milestone. I'll still be using VB, because that's the programming language I'm supposed to use for my first year at college, but C is my objective. VB.Net is just the "gateway drug" enroute to the good shit.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

You'd better start with C right off the bat, geeze. If you don't like it now I'm not seeing anything months of C# could do.
A programming language is more than just the underlying syntax. If your algo-building skills/patterns don't fit the various elements of the language you won't use it efficiently anyway.
And going through another language won't do anything to that.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
ZH/Franky

Post by ZH/Franky »

grinvader wrote:You'd better start with C right off the bat, geeze. If you don't like it now I'm not seeing anything months of C# could do.
A programming language is more than just the underlying syntax. If your algo-building skills/patterns don't fit the various elements of the language you won't use it efficiently anyway.
And going through another language won't do anything to that.
Well, I've looked at some C code recently and unlike before, I can make a pretty good guess as to what many of it does. All I need to do now is learn it. I doubt C# will help me, but it's still good to know another language anyway (even if you still end up with the same .NET code when you compile it). I never said I don't like C (or did I? if I did, I was probably posting at 3 am).
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

grinvader wrote:You'd better start with C right off the bat, geeze. If you don't like it now I'm not seeing anything months of C# could do.
A programming language is more than just the underlying syntax. If your algo-building skills/patterns don't fit the various elements of the language you won't use it efficiently anyway.
And going through another language won't do anything to that.
I would say the more languages you know, the easier it is to pick subsequent ones up as there are more similarities than differences. Someone like you or I are most likely capable of picking up nearly any language in a short amount of time adjusting to syntax, conventions, and mentality of that language.

My point is I wouldn't say learning a second language is useless toward learning a third language. However, I would advise sticking with one language and start to learn it well before moving on to any others or you'll end up not really understanding either language. It takes a lot longer than most people think to really learn a programming language. There's a lot more to programming than loops, variables, and functions. Newcomers often think they're ready to move on because they can write a few functions using some loops and variables.
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
ZH/Franky

Post by ZH/Franky »

Nightcrawler wrote:
grinvader wrote:You'd better start with C right off the bat, geeze. If you don't like it now I'm not seeing anything months of C# could do.
A programming language is more than just the underlying syntax. If your algo-building skills/patterns don't fit the various elements of the language you won't use it efficiently anyway.
And going through another language won't do anything to that.
I would say the more languages you know, the easier it is to pick subsequent ones up as there are more similarities than differences. Someone like you or I are most likely capable of picking up nearly any language in a short amount of time adjusting to syntax, conventions, and mentality of that language.

My point is I wouldn't say learning a second language is useless toward learning a third language. However, I would advise sticking with one language and start to learn it well before moving on to any others or you'll end up not really understanding either language. It takes a lot longer than most people think to really learn a programming language. There's a lot more to programming than loops, variables, and functions. Newcomers often think they're ready to move on because they can write a few functions using some loops and variables.
Don't get me wrong, most of my attention will still be focused on VB.Net. I will kind of start with C#, but progress will be slower. VB.NET is my language of choice at the moment. It will take at least a year or a bit more to become completely accustomed to it, even longer to actually be good at coding, but I've made a lot of progress over the last few months. 3 months ago, I only knew how to write a hello world program. I'll only get a massive focus on C# when I've really learned some of the more advanced things in VB.

I mean, NC, grin, nach, etc, how long have you guys been coding? How long did it take you to really begin mastering it?
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

Total experience getting over 20 years now. Classic BASIC (3 years before i coded interesting stuff) > pascal (weeks but quickly went to) > C (weeks before i got the hang of most of it, language of choice) > ASM (a couple months for x86) pathway, if we forget the minor stuff I was forced to do at school and didn't have any interest in (logo, caml, vb).

Not interested in mastering C++ for various reasons, main being critical brain patterns incompatibility.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
ZH/Franky

Post by ZH/Franky »

grinvader wrote:Total experience getting over 20 years now. Classic BASIC (3 years before i coded interesting stuff) > pascal (weeks but quickly went to) > C (weeks before i got the hang of most of it, language of choice) > ASM (a couple months for x86) pathway, if we forget the minor stuff I was forced to do at school and didn't have any interest in (logo, caml, vb).

Not interested in mastering C++ for various reasons, main being critical brain patterns incompatibility.
So you started programming in 1988/1989? Oh man, you've been at it for a long time. What was the first computer you programmed on, if you don't mind my asking?

There's this guy in my computing class that's been coding since he was 10 years old. He's really good. I asked him what he's interested in right now, and he says that right now he writes cheat engines and bot programs for an online game called "Tibia". His language of choice is C++. He's the same age as me (17), so he's been coding for 7 years now. I've been coding for 3 months.
He was actually the one who introduced me to python (it's the language he first started with), when I asked him what language he would recommend for newcomers to start off with.

PS:
I've heard some negative criticism of C++, but what's wrong with it? How does it compare to pure C?
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

Just google it, but you might of course not understand some of the arguments (yet?).

http://esr.ibiblio.org/?p=532
http://www.evilmartini.com/blog/2008/10 ... d-harmful/
...
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Franky wrote: I mean, NC, grin, nach, etc, how long have you guys been coding? How long did it take you to really begin mastering it?
Well, my story with computers and programming is a weird one.

I hated computers as I was growing up. Seeing these beige machines around, I always wanted to throw them out a window, or blow them up, or drop them from moving vehicles.

Then I was forced into using a computer for over a year straight, I picked up a lot, and mastered my first programming language. I got Stockholm Syndrome and have been programming ever since. I basically pushed the limits of that language farther than they should go, and really freaked out anyone who saw my code - which was massive amounts of spaghetti logic which completely astounded spaghetti experts of the time. I went as far as to write a whole mini OS shell with built in AI to adapt to the user. It was not pretty.

But after programming like that for another year or two, I decided it was time to move into "real programming" and got some books on the popular emerging languages, and wrote a bunch of utilities for things I wanted to automate on my machine, or simplify, and a couple of small games of various sorts. This went on for a couple of years, where I knew a bunch of languages on a basic level, and only looked more into the language if I felt I was stretching things a bit with how I did stuff.

However, I was hardly a good programmer. I would say at that point I was a clever programmer, but my code was absolutely awful, and while I could push a language in a bunch of directions, and figured out a lot of computing principals on my own, I was really clueless in many areas.

Then I enrolled in a modern technology centric university, and decided that the summer before classes would start, I should learn to write clean code so I would be able to submit my homeworks, and not lose points for bad structure, as it was indicated to me by the others I knew in the field that my code was completely unintelligible to everyone else.

Over those two months, I revisited many of the games I wrote, applied better principals, methods, and algorithms to them, reasoning that working isn't enough any more, readability is very important. I got them down from tens of thousands of lines to a few hundred. I also learned to eliminate redundancy and focus more on data driven programming. All these seemed obvious steps I should take for myself, so I can be disciplined in programming, and do well in school. I think it was this realization and acting on it where the master was born.

In college, I decided to sign up for Intro to computer science for software developers AND Intro to computer science for hardware engineers, which seemed to be a very smart move (even though the course selection counselors said it was too redundant to take both). In the former, I learned from a programming genius who had a hard time relating to his students, and taught all types of programming principals and real world techniques. In the latter, I learned from an extremely structured individual on how one must understand every last component of all the code they write, straight down to the hardware level. While technically being the same course, they didn't overlap on anything aside from the pure basics that were occasionally brought up, and really taught me a lot on the scope of things which I initially thought were pretty basic.

Now while class was important there, I spent my evenings in the library, reading up advanced programming books, covering specialized topics, mastering various languages, and programming discipline. I also hunted down some other students who were considered "experts" and had them teach me all the tricks they knew. After a few months, the experts I learned from started asking me on how to do things.

After my first year, I interned at a small company, where my boss gave a ton of weight that it didn't matter if a program worked or not, but if the code itself was written properly or not. A good solution wasn't important. Sitting down and determining what is the "correct solution" was the main focus, and then it was just a matter of having someone write the code. Once the correct solution was discovered, everything else just falls into place. The tools gained there on finding the correct solution was essential.

I spent my nights that summer mastering the entirety of the new languages I picked up, and finally started to know languages in their entirety for the first time since the initial language I learned. I also spent a lot of time online chatting with some experts around the world, and asked a bunch of them to teach me how they would handle situations, till I was able to drain all those masters of everything they knew.

For my second year in college, I was acknowledged by all my teachers and friends as a true master of programming, even though I still had a lot to learn. This year was filled with learning core API theories, algorithms on a deep scale, all kinds of OS nonsense, and a bunch of other topics. I basically rounded out all my knowledge here on various computer programming topics and popular theory.

For my 3rd and 4th years, I basically already got everything I would be able to gather from classes, and started to get more and more annoyed that none of my teachers knew the topics they were teaching as well as I know them. Most of them were also too stuck in theory to grasp the practical. For the few classes that mildly interested me, I would show up to labs, and do my work, and have guys whispering behind my back in spoken languages they thought I didn't understand "oh look, the genius arrived, wonder how many minutes it'll take for him to complete the work, and just step out".

For some classes, I already figured I knew enough about the material due to their similarities to other material I knew, and just would read a one page primer on differences between that class's language and another popular one or something like that. I didn't even bother showing up to class, reading the material, or doing the homework, only bothered with the final exam. I would end up acing the material, with the teacher sometimes commenting to me after marking the exams, that he felt I was the only person who really understood the material, or something along those lines.

During those two years, I spent a lot of time writing my own stuff, and experimenting in all kinds of niche kinds of software development. I also got jobs with various start up companies on developing all kinds of software for this "new fangled internet thing", that was getting really popular. I also took the time to read many books about cutting edge computer theories and practices.

Of course there came the point where I was working on NSRT, and pagefault asked to use some of my code to fix ROM loading in ZSNES, where NSRT seemed to understand the ROM it was looking at better than ZSNES did. Shortly thereafter I joined the ZSNES Team, mostly to fix up the ROM loading code, and clean and tighten in from the disaster that it was (and it still kind of is). Once part of the team, trying to cater to a lot of requests I was getting, I started branching out my knowledge in areas which never really interested me before (compression, video/audio containers and codecs, GUI development, networking, and more). I also was able to learn a lot from masters of a different end of the spectrum where discipline didn't prevail, but still had a lot of unique ideas and techniques to offer.

Today, I'm a well rounded programmer, knowledgeable in practices across almost every area of programming. I know 19 languages (I really should learn 1 more for an even 20). Work for companies that need people to do stuff that's very outside the box. And I spend my own time writing software that interests me, or trying to just do things better than they've been done till now, when I find existing software just doesn't meet my personal expectations on what good software is.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

Franky wrote:What was the first computer you programmed on, if you don't mind my asking?
Thomson MO5.
I've heard some negative criticism of C++, but what's wrong with it? How does it compare to pure C?
My qualms are purely self-borne. I actually like what it can do, just not what you have to do to pull it.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
diminish

Post by diminish »

Wow, that was a piece of an interesting read, Nach.
Gil_Hamilton
Buzzkill Gil
Posts: 4295
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

grinvader wrote:
Franky wrote:What was the first computer you programmed on, if you don't mind my asking?
Thomson MO5.
LOL FRANCE!


My first.


I don't program enough lately(read: at all).
Keep meaning to do something about it, then get distracted.
odditude
Official tech support dood
Posts: 2122
Joined: Wed Jan 25, 2006 7:57 am

Post by odditude »

Atari 400, here, with PILOT and BASIC... although we had replaced it with a 130XE before I was old enough to understand what I was doing instead of blindly copying code from magazines and such. I obviously never got into it with the zeal of Nach or grinvader, though - I was always content to just play games. It didn't help that I had no resources available outside of the mediocre binder manual that shipped with the a400 - if i had a question, there was no way to answer it, and my attention span would quickly shift to oooh shiny game!
Why yes, my shift key *IS* broken.
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

Franky wrote:I mean, NC, grin, nach, etc, how long have you guys been coding? How long did it take you to really begin mastering it?
I got started in programming on a Tandy Color Computer 2 using BASIC. You couldn't do much with those computers without programming something. I was probably around 10 years old. I took an interest on how things worked at an early age giving roots to my engineering interests of today. I got pretty good at it to the point of coding small games. I tried a larger one, but never finished. Then I kind of got away from it for several years.

I didn't get into 'real programming' until high school. I actually nearly failed my first C class in high school. Around this time I also got really into electronics. I took a vocational electronics course in highschool. Things didn't start clicking for me until I got into assembly. That's when the magic started. Between electronics, microprocessors, and programming, everything started to make sense.

By the time I got to college (Electrical Engineering), I aced my first C/C++ courses. I got a near perfect 100 test average in my assembly class. And my knowledge of digital electronics and microprocessors grew further.

I started college in 1999. So, I've been growing as a 'real' programmer for the past 10 years. Professionally, I hold an engineering position and do plenty of embedded programming in both assembly and C. I would consider myself nearing expert level in the embedded arena. I also do PC application programming, but that's a lesser part of my job, and thus my skills have developed more slowly and progression influenced more by my hobbyist activities than professional.

I've since learned and successfully used many languages and APIs. While potentially master of some, I have still not yet mastered complex languages such as C++. I've also always been a step behind others by not having any formal training on design patterns, and algorithm development. Much of that is self taught on demand or figured out through experience.

It takes a long time and a lot of experience to truly know the ins and outs of programming. The 10 years I've had so far aren't enough. I have seen steady progression of my abilities, but can clearly recognize there is much road to be traveled to be a master. I take the term 'master' seriously. I don't think it's something one could achieve in a few months or even a year or two.

There isn't a problem I couldn't solve with my programming abilities, but it's the solution chosen, and how it's implemented that sets the masters apart. That's the area I am still developing in.

We all also have our strengths too. If Nach and myself were combined into a single programmer for example, we'd be pretty wicked. I think our strengths would compliment the others potential weaknesses well. I
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

Nightcrawler wrote:I think our strengths would compliment the others potential weaknesses well. I
would like to read the end of your post, if that's possible.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

grinvader wrote:
Nightcrawler wrote:I think our strengths would compliment the others potential weaknesses well. I
would like to read the end of your post, if that's possible.
Maybe a Vampire killed him.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Nach wrote:
grinvader wrote:
Nightcrawler wrote:I think our strengths would compliment the others potential weaknesses well. I
would like to read the end of your post, if that's possible.
Maybe a Vampire killed him.
Good chance the Metroids got to him first.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Deathlike2 wrote:
Nach wrote:
grinvader wrote:
Nightcrawler wrote:I think our strengths would compliment the others potential weaknesses well. I
would like to read the end of your post, if that's possible.
Maybe a Vampire killed him.
Good chance the Metroids got to him first.
No.

http://www.homestarrunner.com/sbemail10.html
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Gil_Hamilton
Buzzkill Gil
Posts: 4295
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

It was the bugs. They were horrified by grinvader and Nach joining forces, and struck him down before the alliance could be forged.
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

Zombie Jesus, in the board room, with a rake and surprise sex.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Gil_Hamilton wrote:It was the bugs. They were horrified by grinvader and Nach joining forces, and struck him down before the alliance could be forged.
I enjoy your theory.

No more team awesome.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

Nooooooooooooo !!
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Post Reply