1. Home
  2. Computing & Technology
  3. C / C++ / C#

Star Trek Game Conversion Project

By David Bolton, About.com

3 of 8

How I Approached the conversion from Basic to C

To simplify conversion, I loaded the .asc file into a text editor and changed these
IF to if (
R.( to Random()
R. to return
REM to //
F. to for
N. to next. This commented the loop end.
GOS. is a function call. I left these in as reminders for the next pass.
G. is a goto and again I left them in as comments to help unravel the structure.

Note that Gosub (GOS.) translates to a void function call, which returns no values.

Overall Approach to Conversion

This is a straight forward program. Though there are less than 150 lines of code, many are multiple statements, like a block { of code } and after conversion to C, it was 6 times as long! There were no comments but with a bit of teasing, the structure of the program wasn't too difficult to unravel.

I went for a multi pass approach.

  • First pass : Cut and Paste each abbreviation to transform it into a C like syntax. Add brackets to correct the syntax of if statements. Change = inside if () to ==.
  • Second Pass. Try and identify the structure. Basic is notorious for "easy to write" spaghetti code, and older Basics use line numbers which does not make reading the code any easier. So identifying subroutines and code blocks was the objective here.
  • Third Pass. Edit to make it compileable. Remove line numbers, change Gosubs to function calls, add variable declarations and hopefully end up with a nearly working program.
  • Fourth Pass. Test, test, and test.

  • On the next page Converting by Cut and Paste
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. Projects
  5. Star Trek Conversion
  6. My Conversion Strategy

©2009 About.com, a part of The New York Times Company.

All rights reserved.