Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Runtime error 215?

Posted on 1998-09-25
8
Medium Priority
?
2,858 Views
Last Modified: 2008-01-16
First off, I don't know what the heck runtime error 215 is. I'm pretty sure it's some sort of math thing, like multiplying by this...or doing that...something.  Allow me to explain when I get this error:

I use a formula "Position:=320 * PosY + PosX" (Thanks Scrappy) to calculate the position of a pixel, and do all this stuff to figure out the color of that pixel and whatnot.  Anyhow, when the pixel is above the upper half of the screen, everything works fine, but as soon as it gets below the upper half, i get "Runtime error 215".

I'm in MCGA mode, and PosY and PosX are the coords for pixel placement, instead of using a number between 1 and 64000
 
If figured out it happens when PosY is 104 (that's the source of the error, not the PosX)  So 320 * 104 for some reason gives me this error?  I don't know...can anyone help?  
Thanks
0
Comment
Question by:hansell
8 Comments
 

Author Comment

by:hansell
ID: 1215690
Edited text of question
0
 

Author Comment

by:hansell
ID: 1215691
Edited text of question
0
 

Author Comment

by:hansell
ID: 1215692
Edited text of question
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
LVL 5

Expert Comment

by:scrapdog
ID: 1215693
I think I know exactly what your problem is.  You declared Position as an Integer.

An Integer can only hold values between -32768 and 32767.

104*320 = 33280

and this will cause an overflow error, since 33280 is > 32767.


To remedy this, your best bet is to declare position as type Word.  The Word type uses the same amount of memory as the integer type, but the range of values is from 0..65535

When you declare your variable, do it like this:

Position :Word;


rather than this:

Position :Integer;


A variable of type word can safely handle what you are doing, because it seems that your highest value of position is 64000, and word can handle this.


In the future, if you have this error again in another program, remember the ranges of these types:

Integer   -32768 to 32767
Word      0 to 65535
Longint   -2147483648 to 2147483648

If, for example, you need an integer that will require values greater than 32767, you can use Word, or Longint to suit your needs.

Integers and Words are stored using 2 bytes, and Longints are stored using 4 bytes, if you're curious.

Anyway, try using type Word in your program and it will eliminate the error.  

scrappy
0
 
LVL 3

Expert Comment

by:daitt
ID: 1215694
I think the answer is absolutely exact. Why we don't close this question?
0
 

Author Comment

by:hansell
ID: 1215695
Your answer sounded great, but I'm still getting the error.  I've tried position:word and position:longint...

I get the Error 215:Runtime Error at the following line:

Position:=320 * PosY + PosX;

It's exactly like that....PosY is still 104 when i get this error...any other ideas?  

I saw something about a divide by zero bug with 200mhz cpu's but i'm not dividing so...btw my cpu is a 233mhz pentium if that helps?

Any other ideas?

0
 

Author Comment

by:hansell
ID: 1215696
I guess my above comment didn't reject the answer...

Why doesn't Word or LongInt work?  I see why it should...
0
 
LVL 1

Accepted Solution

by:
ow earned 280 total points
ID: 1215697
Scrappy is right at the bottom: 215 is an arithmetic overflow error and 320x104 exceeds the maximun value of integers.
But as the error is caused by the overflow and not by the assignement, you must use longint for "PosX" rather then for "Position".

Regards
  ow

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Aerodynamic noise is the cause of the majority of the noise produced by helicopters. The inordinate amount of noise helicopters produce is a major problem in the both a military and civilian setting. To remedy this problem the use of an aerogel coat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question