Solved

Runtime error 215?

Posted on 1998-09-25
8
2,667 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now