 GW2QB 1.004 - GWBasic to QBasic Source Code converter for Windows
 (C)2011 PeatSoft (05-18-2011)
 www.xs4all.nl/~hwiegman
 hwiegman@xs4all.nl

 ----------------------------------------------------------------------------

 GW2QB converts GWBasic ASCII source code files into QBasic files.

 ----------------------------------------------------------------------------
 
 WHAT DOES GW2QB?

   - Splits lines with multiple statements:

           A = 1: B = 2
             A = 1
             B = 2

           A = 1: B = 2 'initialize
             A = 1
             B = 2 'initialize

   - Makes IF THEN ... END IF blocks from IF statements:

           IF A = 1 THEN B = 2
             IF A =1 THEN
                 B = 2
             END IF

           IF A = 1 THEN B = 2 ELSE B = 3
             IF A =1 THEN
                 B = 2
             ELSE
                 B = 3
             END IF

   - Splits lines beginning with IF and containing a NEXT statement:

           IF A <> 1 THEN B = 2: NEXT I
             IF A = 1 THEN EXIT FOR
             B = 2: NEXT I

       Lines with multiple IF or ELSE statements are ignored.
       Supported are:
         a. IF X z Y THEN
         b. IF X z Y AND/OR X z Y THEN
       where X and Y are expressions
             z is a relational operator (=, <>, <, >, <=, >=)

   - Makes IF THEN ... END IF blocks from lines with IF THEN ... GOTO:

               IF A > 1 THEN GOTO 200
               B = 2
           200 GOSUB 300

               IF A <= 1 THEN
                   B = 2
               END IF
               GOSUB 300

       Supported are:
         a. IF X z Y THEN GOTO linenumber
         b. IF X z Y AND/OR X z Y THEN GOTO linenumber
       where X and Y are expressions
             z is a relational operator (=, <>, <, >, <=, >=)

   - Makes DO ... LOOP blocks from lines like:

               200 A$ = INKEY$
                   IF A$ = "" THEN GOTO 200

                   DO
                       A$ = INKEY$
                   LOOP WHILE A$ = ""

               200 A$ = INKEY$
                   GOTO 200

                   DO
                       A$ = INKEY$
                   LOOP

   - Moves blocks to replace GOTO statements:

               200 GOTO 300
               250 A(0) = 1: RETURN
               300 DIM A(10)
                   GOSUB 250
                   END
               
               200 DIM A(10)
                   GOSUB 250
                   END
               250 A(0) = 1: RETURN

       NOTE: the code can become difficult to survey.

   - Removes unused line numbers.
   - Checks for duplicate line numbers.
   - Places remaining line numbers on empty lines.
     Places empty lines before line numbers when they are the start of a
     GOSUB routine.

   - Checks line numbers in GOTO, GOSUB, RETURN, RESTORE, RESUME and RUN statements.
   - Indents lines between FOR ... NEXT, WHILE ... WEND, IF THEN ... END IF
     and DO ... LOOP statements.

       Set this with the commandline option '/ix' where x is a number between
       0 and 8, or x=n which keeps the original indentation from the input
       file. Default is x=4.
       Note: tab characters in the input file are replaced by a single space.

   - Moves COMMON statements at the top of the code.
     If there are no DIM statements, a new DIM statement is inserted before
     the COMMON statement.
   - Moves DEF FN statements at the top of the code when a DEF FN function is
     called before it is defined.

   - Moves DEFtype statements at the top of the code when there is only one
     DEFtype statement.
     Moves DIM statements at the top of the code when there are less than two
     DEFtype statements and the DIM dimensions are indexed by numbers, not by
     variables and if the code does not contain REDIM or ERASE statements.
     Moves OPTION BASE statements at the top of the code.

   - Remarks rubbish:
       statements beginning with illegal characters eg. '('
   - Remarks keywords used in other languages such as PLOT
   - Remarks abandoned keywords: NEW, SAVE, LOAD filespec, LIST, DEF USR
   - Remarks ELSE statements if they are not preceded by an IF keyword
   - Changes LOAD filespec,R to CHAIN filespec
   - Changes invalid TIME$ statements: TIME$="x" -> TIME$="0x:00"
   - Changes various typo errors: RIGHTS, SPC79)
   - Renames illegal variable names: ACCESS, BASE, CONST, EXIT, IS, etc.
   - Inserts spaces in invalid FIELD statements:
       FIELD#1,2asB$ -> FIELD#1,2 as B$
   - Changes the following commands in PLAY statements:
       Xstringvariable into "X"+VARPTR$(stringvariable)
       command=variable into "command="+VARPTR$(variable)
   - Changes CHAIN [MERGE] "cfile" [,[linenum][,ALL][,DELETE range]] to
       CHAIN "cfile"

       QBasic does not support the MERGE, ALL, DELETE and linenum commands.

 ----------------------------------------------------------------------------

 WHAT DOES GW2QB NOT?

   - checking for:
       incorrect code such as: CC = CCAND 15
                               CC = "string"
                               C$ = "123";
       missing : between keywords
   - convert CALL statements into CALL ABSOLUTE 
   - move DIM statements at the top of the code when they are indexed by
     variables
   
     NOTE: a 100% correct conversion is nearly impossible, so you'll have
           to modify the code yourself if QBasic reports an error.

 ----------------------------------------------------------------------------

 DO IT YOURSELF

   - Try to move DIM statements at the top of the code if possible.

 ----------------------------------------------------------------------------

 WHAT IS NEW?
   0.01 (06-07-2001) - Initial release (MS-DOS)
   1.00 (05-13-2011) - First release for Windows

 ----------------------------------------------------------------------------

 BUG REPORTS
   If you have bug reports, comments, suggestions or questions
   please email me. Thanks.

   Email: gammon@xs4all.nl

 ----------------------------------------------------------------------------

 LEGAL
   
   You are using GW2QB at your own risk, no responsibility is taken for
   damages to your computer system.

   Feel free to distribute this program, as long as the files remain
   intact. You may not use it for personal or any other gain without my
   consent.

 ----------------------------------------------------------------------------
   Thanks for downloading. Have fun!
