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 / Going up a directory

Author
Message
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 4th Jul 2013 09:19
I seem to be having trouble getting to files that are in a different directory than my game. As I've mentioned before, I'm making an Olympics game, so I created one folder for each sport (finished air rifle and am working on weightlifting) and another folder for all of the flag BMPs. However, I can't seem to get to the flag files unless I put them in the same folder as the application. Obviously, I don't want a copy of the same folder in each sport's folder.

How do I go up a directory in my app? I tried using "..\Flags\File.bmp" but that doesn't seem to work.
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 4th Jul 2013 10:50
Try

DIR ..

Cheers Ron.

Programming is learning
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 4th Jul 2013 11:51
Quote: " I tried using "..\Flags\File.bmp" but that doesn't seem to work."
This would access the folder "Flags" in the current folder, if there was an folder called "Flags" in the current folder. I use CD ".." to go back one folder. Have fun

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jul 2013 14:26
Quote: "I use CD ".." to go back one folder."


Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Jul 2013 15:07
OR ..\..\OtherFolder\OtherFile.bla

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jul 2013 16:14
Hi there.

@PirateJohn You can use the whole path to folder or cd ".." as mentioned. I you are doing something like a file browser try this:



I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Jul 2013 22:06
I think ".\" goes up one folder and "..\" is for the root directory.

D.D.
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 4th Jul 2013 23:43
I thought ".\" was the current directory and "..\" the parent directory.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jul 2013 03:13
What shellfish said.

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 5th Jul 2013 05:54 Edited at: 5th Jul 2013 07:26
Unless you need a list of all the files in a certain folder, I'd recommend avoiding .\ and ..\ and CD and DIR.

Just use the regular "relative" path names. So load a player object like:
Load Object "models\player\elf\body.x", 10

If you can't make due with relative paths then do yourself a big favor and record the programs default folder path at the beginning of your program. I can't remember the exact name of the command but its something like this:

Get Current Folder -or- Get Current Dir$

So at the beginning of the program add:
Global Game_Path$
Game_Path$ = Get Current Dir$()

Then when you need to navigate around you can do:
CD Game_Path$

And then use CD with the relative paths to end up in the proper place. You might have all sorts of functions moving that folder navigation pointer all around. Doing it this way reduces the chance they will interfere with each other. It also allows you to consistently use relative paths for everything.

On second thought I'd probably just use CD once but add the global and local paths each time. CD Game_Path$ + "\" + Local_Path$. I'd never use CD "..\".

I'll also add that I never use CD to navigate folders unless I am forced to by DBPro commands. The only reason I can think of is the file/folder checklist for getting all the files in a folder. I use it in all of my editors for loading/saving work and in the game for displaying available maps since I haven't decided on a process for listing the maps in a prettier way than a simple file list. Eventually it will be replaced with an episode title and thumbnail.

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 5th Jul 2013 07:34
Yeah, I kinda do need all of the files in one folder. The reason is that I am making multiple sports (it's the Olympics, after all) so I have one folder for all of my shooting game files and one folder for all of my weightlifting files. As I add sports, they will all get separate folders.

The files that are unique to that sport will go into that sport's folder, but the national flags are common to all of the games, so I have to put that in a higher folder. If I were to try including all of the sports' game files in the same folder, it wouldn't be long before I ended up with one big hot mess, especially after I add a few more sports such as rowing, track, and so on.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jul 2013 17:26
Quote: "Get Current Folder -or- Get Current Dir$"

App Dir() - Matrix 1 plugins.

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]

Login to post a reply

Server time is: 2026-07-07 08:19:05
Your offset time is: 2026-07-07 08:19:05