Solved

Runtime error 215?

Posted on 1998-09-25
8
2,721 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

 
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 70 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Let's recap what we learned from yesterday's Skyport Systems webinar.
Part One of the two-part Q&A series with MalwareTech.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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