啟主列

培基BASIC也,解釋編程語言也。初行於耶歷一九六四,纂後毋須編譯,解釋可行也。

行號型

若夫此類,蓋句首行號也。解釋器依行號而行,順勢而下,然世人詬以行號,以為麵條。

10 INPUT "爾何名: ", U$
20 PRINT "無恙 "; U$
30 INPUT "爾欲星幾何: ", N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "其餘? ", 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 "請歸 "; U$
140 END

結構型

若夫此類,行號更易,標籤代之。

INPUT "爾何名:  ", UserName$
PRINT "無恙 "; UserName$
DO
  INPUT "爾欲星幾何 ", NumStars
  Stars$ = STRING$(NumStars, "*") 
  PRINT Stars$
  DO
    INPUT "其餘? ", Answer$
  LOOP UNTIL Answer$ <> ""
  Answer$ = LEFT$(Answer$, 1)
LOOP WHILE UCASE$(Answer$) = "Y"
PRINT "請歸 "; UserName$

對象型

若夫此類,編譯器代之以解釋器,自立可行。

Public Class StarsProgram
   Public Shared Sub Main()
    Dim UserName, Answer, stars As String, NumStars As Integer
    Console.Write("爾何名: ")
      簿名= Console.ReadLine()
      Console.WriteLine("無恙 {0}", 簿名)
        Do
            Console.Write("爾欲星幾何 ")
            星之數 = CInt(Console.ReadLine())
             = New String("*", NumStars)
            Console.WriteLine()
            Do
                Console.Write("其餘? ")
                 = Console.ReadLine()
            Loop Until Answer <> ""
             = .Substring(0, 1)
        Loop While .ToUpper() = "Y"
        Console.WriteLine("請歸 {0}", 簿名)
    End Sub
End Class