Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / illegal object number???????

Author
Message
Graysire
12
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 15th Jan 2014 19:16
this code will return an illegal object number...why?
if you need more code ask




mx = mousex() : my = mousey() : mc = mouseclick()

if mc = 1

thisOb = pick object (mx,my,firstOb,lastOb)
cs = object size(thisob)
scale object thisOb, cs-50,cs-50,cs-50
cs=0
endif
if cs<50 then exclude object on thisOb
cs=0
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Jan 2014 19:23
Looks like you have a FOR/NEXT that star with 0...we can not have object zero.

I'm not a grumpy grandpa
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Jan 2014 20:46
make sure firstOb and lastOb refer to valid objects.

also, i forget if variables are case sensitive, but you are checking size of thisob but assigning variable thisOb, possibly therefore checking the size of object 0 instead of the picked object

SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 15th Jan 2014 21:18
Plus, Pick Object returns 0 (an invalid ID) if it can't find any object at the coordinates it's given, so it's a good idea to fool-proof it by making sure thisob is more than 0 before checking object size and stuff
Graysire
12
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 16th Jan 2014 19:19
Thanks samKM
if thisOb > 0 was what we needed

Login to post a reply

Server time is: 2026-07-06 07:51:14
Your offset time is: 2026-07-06 07:51:14