討論區: Forum of Decimal BASIC (Thread #42090)

Program Won't Compile (2020-03-25 19:55 by toml_12953 #84633)

The program below works fine in Decimal BASIC interpreter but won't compile because every line must have a number if GOTO or RETURN are used.
Is that something that you would consider changing?
The lines without numbers aren't referenced anywhere in the program.

1000 DIM E(100000), C(100000)
1010 INPUT PROMPT "HOW MANY DIGITS DO YOU WANT PI TO? ":A
1020 LET B=100
LET A=A+1
1030 LET A=(A+5)/2
1040 LET LM=A+5
2000 REM
2005 FOR G=1 TO 2
GOSUB 2500
NEXT G
LET A=A-.5
2010 GOTO 3005
2500 REM
2505 GOSUB 7000
2510 GOSUB 8000
LET H=2
LET I=J
GOSUB 4000
2515 IF K<0 THEN
GOTO 2516
ELSEIF K=0 THEN
GOTO 2517
ELSE
GOTO 2518
END IF
2516 GOSUB 6000
GOTO 2520
2517 PRINT "K=0"
STOP
2518 GOSUB 5000
2520 LET J=J+2
LET K=-K
LET H=1
LET I=(G-1)*214+25
2525 GOSUB 4000
IF G-1<0 THEN
GOTO 2527
ELSEIF G-1=0 THEN
GOTO 2530
ELSE
GOTO 2527
END IF
2527 GOSUB 4000
2530 IF Q<0 THEN
GOTO 2510
ELSEIF Q=0 THEN
GOTO 2535
ELSE
GOTO 2510
END IF
2535 RETURN
3000 REM
3005 PRINT "THE VALUE OF PI TO";2*A-5;"DECIMAL PLACES"
3010 PRINT "3.";
3015 LET Q=0
3020 FOR L=4 TO 52 STEP 2
GOSUB 3200
NEXT L
3025 LET Q=Q+25
PRINT " ";
GOTO 3020
3200 REM
3205 LET E1=INT(E(L/2+Q)/10)
PRINT STR$(E1);
3210 IF (L+Q*2-3-(2*A-5))<0 THEN
GOTO 3215
ELSEIF (L+Q*2-3-(2*A-5))=0 THEN
GOTO 9005
ELSE
GOTO 3215
END IF
3215 IF ((L-3)/5-(INT((L-3)/5)))<0 THEN
GOTO 3217
ELSEIF ((L-3)/5-(INT((L-3)/5)))=0 THEN
GOTO 3217
ELSE
GOTO 3220
END IF
3217 PRINT " ";
3220 LET E2=E(L/2+Q)-10*E1
PRINT STR$(E2);
3225 IF (L+Q*2-2-(2*A-5))<0 THEN
GOTO 3230
ELSEIF (L+Q*2-2-(2*A-5))=0 THEN
GOTO 9005
ELSE
GOTO 3230
END IF
3230 IF ((L-2)/5-(INT((L-2)/5)))<0 THEN
GOTO 3233
ELSEIF ((L-2)/5-(INT((L-2)/5)))=0 THEN
GOTO 3233
ELSE
GOTO 3235
END IF
3233 PRINT " ";
3235 RETURN
4000 REM
4005 LET N=0
LET Q=0
4010 FOR L=1 TO A
GOSUB 4500
NEXT L
4015 RETURN
4500 REM
4505 LET N=N+C((H-1)*LM+L)
LET O=INT(N/I)
4510 LET P=N-I*O
LET Q=Q+P+O
LET C((H-1)*LM+L)=O
4515 LET N=B*P
RETURN
5000 REM
5005 LET R=0
FOR L=INT(A) TO 1 STEP -1
GOSUB 5500
NEXT L
5010 RETURN
5500 REM
5505 LET S=E(L)+C(LM+L)+R
LET R=0
5510 IF S-B<0 THEN
GOTO 5520
ELSE
GOTO 5515
END IF
5515 LET S=S-B
LET R=1
5520 LET E(L)=S
RETURN
6000 REM
6005 LET T=0
FOR L=INT(A) TO 1 STEP -1
GOSUB 6500
NEXT L
6010 RETURN
6500 REM
6505 LET U=E(L)-C(LM+L)-T
LET T=0
6510 IF U<0 THEN
GOTO 6515
ELSE
GOTO 6520
END IF
6515 LET U=U+B
LET T=1
6520 LET E(L)=U
RETURN
7000 REM
7005 FOR LP=1 TO LM*2
LET C(LP)=0
NEXT LP
7010 IF G-2<0 THEN
GOTO 7015
ELSEIF G-2=0 THEN
GOTO 7020
ELSE
GOTO 7015
END IF
7015 FOR LP=1 TO A
LET E(LP)=0
NEXT LP
7020 LET C(1)=16/G^2
LET I=(G-1)*234+5
LET H=1
GOSUB 4000
7025 LET J=1
LET K=3-2*G
RETURN
8000 REM
8005 FOR LP=1 TO A
LET C(LM+LP)=C(LP)
NEXT LP
8010 RETURN
9000 REM
9005 PRINT
END

回覆 #84633×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

Re: Program Won't Compile (2020-03-26 09:54 by SHIRAISHI Kazuo #84634)

Every line must have a number if GOTO or RETURN are used.
Note that ANSI Full BASIC demands every line has a number, and GOSUB is planed to be removed in future standard.
回覆: #84633

回覆 #84634×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

Re: Program Won't Compile (2020-04-02 07:23 by SHIRAISHI Kazuo #84679)

The line that need to have a line number is the line next to a GOSUB line.

回覆: #84633

回覆 #84679×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入