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 / Runtime error 506 {beginner}

Author
Message
Rikukarasuma
14
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 18th May 2011 19:56
hey im a beginner at darkbasic pro and im having a problem spotting whats wrong with this code and this error, if anyone could give me a hand I would be very grateful.
Here is the error and code
Runtime error 506 - could not load image at line 9


Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 18th May 2011 20:26 Edited at: 18th May 2011 20:41
You are trying to load the image "background.jpg" but failing because the id you have given it 'bgID' has not been set to anything. You have set it in the vars subroutine but not set it globally so when you return from vars the info is lost.

Change bgID = 100 to:
global bgID = 100 (along with all the other variable declarations) and it will work ... until you get to this line:

Where you will have a similar problem whereby platformID(i) is not set to anything. Give each array value a number above zero and all is good.
[edit]Which I see you have done here:

but that part of the code is never called.

Although you really don't need to load the same image three times. Just load it once and use the same imageID for each sprite.

[Edit]
There are then several other issues you need to address. For example, this:

Is EXACTLY the same is this:


Rikukarasuma
14
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 18th May 2011 21:08
Thanks for helping me with that error Im trying the just load the image once and use the same ID but i keep getting another runtime error this one says illegal image number at line yada yada.

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 18th May 2011 23:03
Your reply isn't showing here yet due to you still being on 'probation' as a new forum member. However, I have been emailed with your reply and the only reason reason you would get an 'illegal image number at line yada yada' error message is because you are trying to do what I said in the opening line of my previous response:

This will cause the error you are getting:

Because bgID is not a global variable and the value that you set in the vars subroutine is lost when you return from the subroutine. So, it is like saying load image "background.jpg", 0 and 0 is an illegal image number.

However, because an image number ID will never change it would be better to set it as constant rather than a global variable. So try putting
at the beginning of your code instead.

Sorry if replying to a post that hasn't appeared yet is causing confusion but I thought I'd get it out of the way.

Login to post a reply

Server time is: 2025-05-18 02:22:47
Your offset time is: 2025-05-18 02:22:47