thomas99
thomas99

Reputation: 11

Issues with MID$ function

I'm trying to print out every character of a given string on a new line.

1 INPUT ""; A$
2 E%=0
3 IF E% < LEN(A$) GOTO 5
4 END
5 PRINT MID$(A$,E%,E%+1)
6 E% = E% + 1
7 GOTO 3

I keep on getting

ILLEGAL QUANTITY ERROR IN 5

and I don't know why.

Upvotes: 1

Views: 71

Answers (1)

Bill Hileman
Bill Hileman

Reputation: 2836

You have three problems with your code, two of them related.

First, E% should start at 1 not 0. Second, because E% starts at 1, you chould check for <= instead of <. Finally, your MID$() function parameters should be as below:

1 INPUT ""; A$
2 E%=1
3 IF E% <= LEN(A$) GOTO 5
4 END
5 PRINT MID$(A$,E%,1)
6 E% = E% + 1
7 GOTO 3

Next you should look into FOR/NEXT loops.

Upvotes: 1

Related Questions