Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Runtime error 215?

Posted on 1998-09-25
8
Medium Priority
?
2,817 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Check out what's been happening in the Experts Exchange community.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

722 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