Welcome to GoldenGaming. We appreciate your support and hope that you be an active member. Don't Forget To Sign Up!

Welcome to Golden Gaming
Contact an Admin or Moderator for any issues you have
We Are Purchasing A Domain After 100 Members!
You can now use symbols in your username, just don't forget them!

    [Programming] BASIC

    I Am Programmer
    Rookie User
    Rookie User

    Posts : 20

    [Programming] BASIC

    Post  I Am Programmer on Mon Dec 20, 2010 1:53 am

    Unstructured BASIC
    New BASIC programmers on a home computer might start with a simple program similar to the Hello world program made famous by Kernighan and Ritchie. This generally involves simple use of the language's PRINT statement to display the message (such as the programmer's name) to the screen. Often an infinite loop was used to fill the display with the message. Most first generation BASIC languages such as MSX BASIC and GW-BASIC supported simple data types, loop cycles and arrays. The following example is written for GW-BASIC, but will work in most versions of BASIC with minimal changes:
    10 INPUT "What is your name: ", U$
    20 PRINT "Hello "; U$
    30 INPUT "How many stars do you want: ", N
    40 S$ = ""
    50 FOR I = 1 TO N
    60 S$ = S$ + "*"
    70 NEXT I
    80 PRINT S$
    90 INPUT "Do you want more stars? ", A$
    100 IF LEN(A$) = 0 THEN GOTO 90
    110 A$ = LEFT$(A$, 1)
    120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30
    130 PRINT "Goodbye "; U$
    140 END

    Structured BASIC
    Second generation BASICs (for example QuickBASIC and PowerBASIC) introduced a number of features into the language, primarily related to structured and procedure-oriented programming. Usually, line numbering is omitted from the language and replaced with labels (for GOTO) and procedures to encourage easier and more flexible design.
    INPUT "What is your name: ", UserName$
    PRINT "Hello "; UserName$
      INPUT "How many stars do you want: ", NumStars
      Stars$ = STRING$(NumStars, "*")
      PRINT Stars$
        INPUT "Do you want more stars? ", Answer$
      LOOP UNTIL Answer$ <> ""
      Answer$ = LEFT$(Answer$, 1)
    LOOP WHILE UCASE$(Answer$) = "Y"
    PRINT "Goodbye "; UserName$

    BASIC with object-oriented features
    Third generation BASIC dialects such as Visual Basic, REALbasic, StarOffice Basic and BlitzMax introduced features to support object-oriented and event-driven programming paradigm. Most built-in procedures and functions now represented as methods of standard objects rather than operators.
    The following example is in Visual Basic .NET:
    Public Class StarsProgram
        Public Shared Sub Main()
            Dim UserName, Answer, stars As String, NumStars As Integer
            Console.Write("What is your name: ")
            UserName = Console.ReadLine()
            Console.WriteLine("Hello {0}", UserName)
                Console.Write("How many stars do you want: ")
                NumStars = CInt(Console.ReadLine())
                stars = New String("*", NumStars)
                    Console.Write("Do you want more stars? ")
                    Answer = Console.ReadLine()
                Loop Until Answer <> ""
                Answer = Answer.Substring(0, 1)
            Loop While Answer.ToUpper() = "Y"
            Console.WriteLine("Goodbye {0}", UserName)
        End Sub
    End Class

      Current date/time is Fri Jun 23, 2017 8:11 am