06-25-2011, 10:05 AM | #1 | |
Fun with converting old TI-99/4A BASIC to C#
Here is a link to a tutorial that I typed up where you could convert an old Hello World application from a 30 year old toy computer into a real console application written in C#, this is a fun example, and I look forward to cracking open even more possibilities from days of old:
Here is the old TI-99/4A BASIC code: Quote:
Code:
using System; namespace HelloWorldExample { class InitializeScreen { public static void Main() { ClearScreen(); } private static void ClearScreen(); { Console.BackgroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.Black; Console.Clear(); HelloWorld.PrintHelloWorld(); } } } Code:
using System; namespace HelloWorldExample { class HelloWorld { public static void PrintHelloWorld() { Console.WriteLine("HELLO WORLD!!"); ScrollScreen(); } private static void ScrollScreen() { for (int x = 0; x < 10; x++) { Console.WriteLine(Environment.NewLine); } EndProgram(); } private static void EndProgram() { Console.WriteLine("PRESS <ENTER> TO END PROGRAM: "); Console.ReadKey(); } } }
__________________
PC Specs (a.k.a. "Galacticus Prime"): http://pcpartpicker.com/p/7Vk7FT |
||
06-25-2011, 11:53 PM | #2 |
Re: Fun with converting old TI-99/4A BASIC to C#
Interesting... A fair amount of BASIC I imagine could be easily abstracted if you wanted to do some rather easy conversion... It would be horribly inefficient though.
There are a lot of things that one must consider when porting from one language to another, |
|
06-27-2011, 03:35 AM | #3 |
Re: Fun with converting old TI-99/4A BASIC to C#
What would be cool IMO would be a modern program that loads old BASIC files and interprets them.
__________________
[...] We view customers as complete morons that will never catch on and [...] we're lying to them all the time. (Gabe Newell, Valve) I'm the worst enemy in film-making and a completely talentless idiot. (Uwe Boll) Faith is why you are wrong. (Crosma) |
|
06-27-2011, 05:46 PM | #4 |
Re: Fun with converting old TI-99/4A BASIC to C#
I suppose you could use DOSBox and QBASIC... But I would hardly call QBASIC "Modern"...
|
|
06-27-2011, 07:42 PM | #5 |
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 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; } } } }
__________________
PC Specs (a.k.a. "Galacticus Prime"): http://pcpartpicker.com/p/7Vk7FT |
|
06-27-2011, 09:48 PM | #6 |
Re: Fun with converting old TI-99/4A BASIC to C#
your examples make no practical sense. In the real world you probably have thousands of these programs. Doing conversions on that scale will likely be error prone and problematic. A better solution would be to write hooks to say an enterprise service bus. That would allow the old programs to pass data back and forth with modern programs. Then the next step will be to get a replacement of the old programs and make the same hooks to the service bus. Then voila, swap out the old with the new.
__________________
big badass nasty weapons here.... |
|
Bookmarks |
|
|