tags:

views:

81

answers:

4

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

+1  A: 

I don't think there is an ELSE keyword in vintage basic, which is why you're getting the unexpected 'E' error.

I assume vintage BASIC is unstructured BASIC, you can refer to the wikipedia article for an example: http://en.wikipedia.org/wiki/BASIC_programming_language

Also, you have some duplicate line numbers for 26 and 27, which explains the other errors.

dcp
+1  A: 

Are you sure your version of BASIC has ELSE? Not all have...

I guess you are learning to program, right? May I ask a question? Why Basic?
I think there are a lot of more useful and powerful (and mainly using modern practices of programing) languages to learn that you can use in a graphic OS and they are not more complicated to learn like Python for example (my son has your age and he is loving python). It's a simple language for simple things but very powerful if you need (and complicated too!).

Good luck!

laurent-rpnet
From my (very far) experience in Basic, this IF...THEN has no ELSE but you can have more than one statement on the THEN clause using `:` like `... THEN A=B : GOTO 13`
laurent-rpnet
BASIC is, well, basic! I'll look into python though. ;)
Windoze NT
+1  A: 

The first two warnings are caused by your program having two lines 26, and two lines 27.

I would guess that the third message comes from your BASIC only supporting IF THEN and not IF THEN ELSE. In this case, you can encode it with IF GOTO.

Pascal Cuoq
A: 

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.

GreenMatt
you can just use `16 GOTO 13`
laurent-rpnet
The script runs perfectly now, but now instead of allowing more commands, finishing FORMAT and attempting to run another simulated application like FDISK causes FORMAT to loop forever until force restart of Command Prompt and Vintage BASIC. Also, is there a way to make the simulator actually format something? I don't know much BASIC yet. Also, short pauses in the script, like a wait function, a generated screen clearing and a short beep at program launch would also be great to add.WindozeNT
Windoze NT
@laurent-rpnet: You're right, that would work. I put the `IF $I <> ...` in to demonstrate how it would be done explicitly, in case that was needed.
GreenMatt
@WindozeNT: Not sure because Basic I used was different (it was on an Apple ][...) but for pause I think you can use `Pause(x)` (x in seconds), beep: `BEEP(x)` or `BEEP(x,y)` x in seconds and y in "Hz" (or switched) and to clear screen it's probably `CLS` or `CLEAR` or `CLR`. To format something... not sure but there is probably a keyword to execute DOS commands like `EXEC` or `CALL` or `!`. At that time it was `CALL` to call assembly subroutines...
laurent-rpnet