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.

Newcomers DBPro Corner / Best way to make your program find itself?

Author
Message
DrEnzyme
18
Years of Service
User Offline
Joined: 22nd Jul 2006
Location: The middle of the Nowhere Desert
Posted: 24th Oct 2006 12:41
One of, if not the most horrible error i've found in Dark Basic is the Cannot find object at line blah blah blah, due to the fact that your game doesn't know where it's directory is located. This is easy to fix on your own computer, but what if you want others to play your game?

My question to you is, what is the best way to fix this problem? A one off subroutine asking the user where the file is? Or a file scanner that stops when it finds where it's directory is located? Or any other solution for that matter?

"Rocket launcher: Not suitable for children under 3 years of age. Contains small parts. Harmful if swallowed."
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Oct 2006 15:58
The *only* time that this happens is if you have run your code without saving it first. Save it first, then everything else is relative to that.

Twu Kai
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 24th Oct 2006 16:07
As in most games, the media is either put inside the EXE, or is like this:



Hope you understand.

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 24th Oct 2006 22:53
I think he means the absolute directory. appname$() returns the full path of the executable.

Confucius Say...
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Oct 2006 00:11
99% of the time if others run your .exe the directory the .exe is at is the working directory.

To be sure you can check if the file exists so you don't get the error:


If you your file structure is like Twu Kai said you'll be fine and you won't need extra code to stop errors like that.
DrEnzyme
18
Years of Service
User Offline
Joined: 22nd Jul 2006
Location: The middle of the Nowhere Desert
Posted: 25th Oct 2006 08:19
Yeah thanks guys. Code Dragon answered my question. And I don't believe what IanM tells me. I downloaded one of the DB games on this site and although all the media was with the program, it couldn't find it. I just want to make sure that this doesn't happen with my game. I guess I'll just save the media in the .exe file like Twu Kai said. Thanks for all your help.

"Rocket launcher: Not suitable for children under 3 years of age. Contains small parts. Harmful if swallowed."
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Oct 2006 09:22
Not believing a mod is like saying you're not really sure this gravity stuff is real... or I think everybody is lieing when they say the world is round.

He was talking about when you run the program from the editor. If you don't save it doesn't know what directory to start in.
DrEnzyme
18
Years of Service
User Offline
Joined: 22nd Jul 2006
Location: The middle of the Nowhere Desert
Posted: 24th Nov 2006 23:41
Oh, because so far every DB game i've downloaded hasn't worked on my computer because it can't find it's media. I think it has something to do with Windows 98 being lame.

"I have defied Gods and demons. I am your shield, I am your sword. I know you, your past, your future."
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 25th Nov 2006 02:38
If you're talking about games where you download the source to run it, here's the problem:

It has nothing to do with Windows 98, (although it is lame in general). If you download a game's media and paste the source into the editor, it won't work. You need to create a project, so the exe will start in the project's file, and if you put the media in there as well, it should work. Otherwise the exe will be put in the TEMP folder, and media's usually not there.

However, I usually put media I download from this site in the TEMP folder so I don't have to create a new project, I can just copy the media, paste the code, and run the game.

DrEnzyme
18
Years of Service
User Offline
Joined: 22nd Jul 2006
Location: The middle of the Nowhere Desert
Posted: 27th Nov 2006 00:00
No i don't download the source, I'm talking about fully-fledged exes here. I download them from places like Caiman free games with all the media in the same place as the exe. When I run them, Ka-Die.

"I have defied Gods and demons. I am your shield, I am your sword. I know you, your past, your future."

Login to post a reply

Server time is: 2024-11-26 05:39:11
Your offset time is: 2024-11-26 05:39:11