Search code examples
dosbasic

How do I fix this BASIC compilation error?


I have a problem compiling a program I made in BASIC. It's a DOS simulator that I was making in attempts to see if it is posssible to write an operating system entirly in BASIC. Every time I try to compile, I get these messages:

!SYNTAX ERROR IN LINE 15, COLUMN 50
 UNEXPECTED E
 EXPECTING : OR END OF LINE

What do I change to sovle this?

10 PRINT 
11 PRINT "Starting..."
12 PRINT 
13 PRINT 
14 INPUT "Type the location of the Command Interpretter:"; I$
15 IF I$ = "C:\WINDOWS\COMMAND.COM" THEN GOTO 14 ELSE GOTO 13
16 INPUT "C:\>"; D$
17 IF D$ = "FORMAT" GOTO 25
18 IF D$ = "FDISK" GOTO 47
19 IF D$ = "HELP" GOTO 16
20 IF D$ = "DIR" GOTO 16
21 IF D$ = "MKDIR" GOTO 16
22 IF D$ = "WIN" GOTO 16
23 IF D$ = "CD" GOTO 16
24 IF D$ = "DEL" GOTO 16
25 PRINT "WARNING, ALL DATA ON REMOVABLE DISK"
27 PRINT "DRIVE A: WILL BE LOST!"
28 INPUT "Proceed with Format (Y/N)"; F$
29 IF F$ = "Y" THEN GOTO 28
30 IF F$ = "N" THEN GOTO 16
31 PRINT 
32 PRINT 
33 PRINT 
34 PRINT "Fotmatting 1.44MB"
35 PRINT "Format complete."
36 PRINT "Writing out file allocation table"
37 PRINT "Complete."
38 PRINT "Calculating free space (this may take several minutes)...................."
39 PRINT "Complete."
40 PRINT 
41 INPUT "Volume Label (11 charchters, ENTER for none)"
42 PRINT 
43 PRINT "              1,440MB total disk space"
44 PRINT "              1,440MB available on disk"
45 PRINT 
46 PRINT "                       512 bytes in each allocation unit."
47 PRINT "                  32,624 allocation units available on disk."
48 PRINT "Volume Serial Number is 326A-1312"
49 GOTO 16
50 PRINT "Incorrect DOS Version"
51 PRINT 
52 GOTO 16

I used Vintage BASIC 1.0.1 as the compiler. Anyone know what's going on? Windoze NT


Solution

  • I note that you've changed the code originally posted, deleting the duplicate line numbers That will make the first part of this answer look weird, but I'll leave it.

    The compiler is telling you that you're re-using the same line numbers. Notice the following section of code?

    26 PRINT "DRIVE A: WILL BE LOST!"
    27 INPUT "Proceed with Format (Y/N)"; F$
    26 IF F$ = "Y" THEN GOTO 28
    27 IF F$ = "N" THEN GOTO 16
    

    The fix is to renumber your lines. Now you know why you don't usually use increments of 1 between lines in languages that require line numbers! (You can likely find - or even write - a tool to do it for you, however.)

    Regarding the error from:

    15 IF I$ = "C:\WINDOWS\COMMAND.COM" THEN GOTO 14 ELSE GOTO 13
    

    I've not run across "Vintage BASIC" before, but assuming the other answers about it not supporting an else are correct, you'll want something like:

    15 IF I$ = "C:\WINDOWS\COMMAND.COM" THEN GOTO 14 
    16 IF I$ <> "C:\WINDOWS\COMMAND.COM" THEN GOTO 13
    

    You may need to replace "<>" with "!=" or whatever your BASIC uses as a not equal to operator. Also, you'll have to do more renumbering, since you already have a line 16.