View Single Post
Old 06-27-2011, 07:42 PM   #5
8IronBob

8IronBob's Avatar
Re: Fun with converting old TI-99/4A BASIC to C#
That's true...but I was just showing how line numbered programming can be converted to OOP through more modern languages like C# and/or Java. Let's see if I can come up with another example that'll be fancier than Hello World...that was just too easy.

All right, here's a program called "Marching Numbers." Now let's see how well we can convert this one:

Original TI BASIC Code:

Code:
10 CALL CLEAR
20 X=0
30 X=X+1
40 IF X>9 THEN 20
50 PRINT X;
60 GOTO 30
Now let's convert this into C# code in OOP fashion, shall we?

Code:
using System;

namespace MarchingNumbers 
{
     class Program
     {
          public static void Main()
          {
               InitializeScreen();  
          }

          private static void InitializeScreen()
          {
               Console.BackgroundColor = Console.Color = Green;
               Console.ForegroundColor = Console.Color = Black;
               Console.Cls();
               NumberMarch.MarchNumbers();
          }
     }

     class NumberMarch
     {
          public static void MarchNumbers()
          {
               int x = 0;
               x += 1;

               Console.WriteLine(x);

               if (x >= 9)
               {
                    x == 0;
               }
          }
     }
}
Now I'm not certain that this conversion would exactly be 100%, but it does show how important it is to be able to determine, based on line number references, where to either create a new class and/or method, and if you need to make an if or a for statement, associate the line numbers, and develop a code block with all the involved lines of code. It's a weird science, I do admit, but there are key elements in older code to look for when attempting to convert it to a newer language. Just throwing that out there.
__________________
PC Specs (a.k.a. "Galacticus Prime"): http://pcpartpicker.com/p/7Vk7FT
8IronBob is offline