string - How do I correct these BASIC errors - Stack Overflow
First time posting here, I'm getting a few errors in an old 1977 BASIC program for the Sol 20 computer.
First error is a "DM error in line 4240":
4220 PRINT " TYPE IN -STOP- TO QUIT ANYTIME"
4230 PRINT
4240 DIM A$(30),B$(30),C$(45),D$(30),E$(30),L$(10),Z$(12)
4250 LET A$="NO SUCH ELEVATION IN MY TAPES, UNDER 360, PLEASE."
4260 PRINT " THE TANK IS ";E;" FEET AWAY."
If I remove the "B$(30)" from line 4240 then the program runs further but I get a "BS error in line 4590" below:
4560 IF I<=0 THEN 5250
4570 IF S=0 OR Z=3 THEN 4590
4580 LET S=-S
4590 LET D=(2*X**3*SIN(2*W)*COS(.5*W)/G*4)
4600 LET D=INT(D/15-(3*S-7))
4610 PRINT
4620 PRINT " ";D;" FEET"
If I remove one "*" after the "X" then the program runs but the range is far too low. Anyone that's familiar with BASIC might be able to see a fault or make a few suggestions.
First time posting here, I'm getting a few errors in an old 1977 BASIC program for the Sol 20 computer.
First error is a "DM error in line 4240":
4220 PRINT " TYPE IN -STOP- TO QUIT ANYTIME"
4230 PRINT
4240 DIM A$(30),B$(30),C$(45),D$(30),E$(30),L$(10),Z$(12)
4250 LET A$="NO SUCH ELEVATION IN MY TAPES, UNDER 360, PLEASE."
4260 PRINT " THE TANK IS ";E;" FEET AWAY."
If I remove the "B$(30)" from line 4240 then the program runs further but I get a "BS error in line 4590" below:
4560 IF I<=0 THEN 5250
4570 IF S=0 OR Z=3 THEN 4590
4580 LET S=-S
4590 LET D=(2*X**3*SIN(2*W)*COS(.5*W)/G*4)
4600 LET D=INT(D/15-(3*S-7))
4610 PRINT
4620 PRINT " ";D;" FEET"
If I remove one "*" after the "X" then the program runs but the range is far too low. Anyone that's familiar with BASIC might be able to see a fault or make a few suggestions.
Share Improve this question edited Nov 17, 2024 at 19:20 Sep Roland 40k10 gold badges48 silver badges89 bronze badges asked Nov 15, 2024 at 21:11 Revive RetroRevive Retro 411 silver badge4 bronze badges2 Answers
Reset to default 3First error is a "DM error in line 4240"
The manual states that this is an attempt to dimension an array more than once. Look for an earlier DIM
statement.
To find out which array triggers the error, write the line as:
4240 DIM A$(30)
4241 DIM B$(30)
4242 DIM C$(45)
4243 DIM D$(30)
4244 DIM E$(30)
4245 DIM L$(10)
4246 DIM Z$(12)
If I remove one "*" after the "X" then the program runs but the range is far too low
Two asterisks in a row mean exponentiation, so simply removing one asterisk in this expression (2*X**3*SIN(2*W)*COS(.5*W)/G*4)
is not equivalent. Use (2*X*X*X*SIN(2*W)*COS(.5*W)/G*4)
instead.
From your comment:
4050 DATA "DEGREE OF ANGLE",0,0,5,20000,15,5.7,100,50
4060 READ B$,R,Q,T,E,F,G,H,I
4065 LET N$="N"
This is where B$ is defined
and from this excerpt of another manual:
A string variable can contain one to ten characters unless its maximum size has been declared as a value larger than 10 in a
DIM
statement.
it is clear that your program is already using the B$ string variable with its default dimension of 10, before your DIM B$(30)
statement tries to declare the maximum size of the string variable. This is not permitted.
For a definitive answer one would need to see the whole program, but precausiously I'd say that simply moving the DIM B$(30)
statement to the very first lines (that get executed) of your program could solve this.
Look for these relevant parts in the manual:
DIM variable(dimensionl, dimension2, ...)
Defines a multi-dimensional numerical array with the number of dimensions specified. C5-17
DIM stringvariable(size)
Declares the number of characters that can be contained in the specified string variable. C5-11
The problem is that B$
has already been defined (explicitly or implicitly) before your line 4240.
Per the documentation, https://www.sol20./manuals/basic5.pdf, DM error means:
Dimension error. Attempt to dimension (DIM) array more than once in program
Also, the default array size is 10, which is why you get the
subscript out of range error
when you remove B$
from the DIM
statement.
- 安卓上市11年 为何说iPhone用户也要感谢它
- 拥抱安卓的诺基亚能否逆势崛起?
- 力压谷歌、苹果,微软凭什么成为软件霸主?
- excel - Sum with multiple criteria and first matches only (excluding duplicates) - Stack Overflow
- javascript - Return a promise that resolves when a event is fired - Stack Overflow
- javascript - Eris read embeds - Stack Overflow
- rust - Why is the compiler asking for Sized, when I already added it? - Stack Overflow
- javascript - Unable to create a framebuffer with an RGBA32F texture - Stack Overflow
- c# - While Downloading the Excel file from a location it is not able to download, showing check internet connection - Stack Over
- c++ - C++20 compile time retrieve size of a vector - Stack Overflow
- Why is my ESP32 task not logging when Wi-Fi is disconnected, but Wi-Fi retry logs are showing up? - Stack Overflow
- window - Strawberry Perl doesn't include Win32::shortcut? - Stack Overflow
- python - Using OpenCV to achieve a top-down view of an image with ArUco Markers - Stack Overflow
- tsx - Does Inversify actually require emitDecoratorMetadata for Typescript? - Stack Overflow
- arkit - Detecting and Using 2 Different Vertical Planes - Stack Overflow
- excel - Are there any advantages to use `Application.Match` on a VBA array instead of looping over it when you only care if an e
- c++20 - Why can't C++ tell return_void and return_value are mutually exclusive? - Stack Overflow