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 / Array file system

Author
Message
Wartorn
17
Years of Service
User Offline
Joined: 24th Oct 2006
Location: Molde, Norway
Posted: 6th Nov 2006 18:14
Im kinda new to arrays, and im making a fake filesystem with arrays..

like this:


But im not sure how to access the 3rd subdirectory, i managed to access the first subdir, but then my code got kinda.. "stuck" there, and i cant continue..

heres my code:



the p() function is just to print...
If someone could help me out of this pickle i would appreciate it alot!
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 7th Nov 2006 04:00
This looks rather confusing to me... But I am not familiar with array files. However, from looking at this piece of code:

hosts(cCURRENTHOST, cCURRENTDIR, x)

I think you need to tell us/show us what all these variables are, since none of these are core commands. Your first listed set up does not use any of these variables either. The x is, of course, self explanatory.

Happy coding,

D
Wartorn
17
Years of Service
User Offline
Joined: 24th Oct 2006
Location: Molde, Norway
Posted: 7th Nov 2006 08:42
Aaahh.. sorry, forgot, cCURRENTHOST just means console current host, which is 1, 2, 3 whatever, the first computer(1) right..
cCURRENTDIR is "directory", the second 1 etc. and ofcourse x is the third (the second subdir)..
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Nov 2006 09:19 Edited at: 7th Nov 2006 09:20
You need to keep the array one dimensional to make it easier to navigate.

I threw together an example of how to do it (I assume you're using Darkbasic Pro since you were working with user defined types).



The above code uses "print" so it may look a bit funny (file sizes and date won't be lined up) but everything you need is right there.

The UDT is like this:



"Computer" I added because you had it.
"Directory" is what directory the file is located in.
"FileType" determines if the file is a directory (1) or a file (2)
"File" is the actual name of the file. This can be either a new directory name or an actual file. You can use this to determine if a directory exists (with filetype being a 1). Once the current directory is changed to this filename any files/directories with that same name as defined in "Directory" will be shown.
"Size" is the file size (doesn't matter if it's a directory)
"Date" is the file date

The program starts as the CDirectory$=nothing which will show all files with nothing as the directory. There's no need to name it "root" because technically if you're in the root directory you're not really in any directory. If you change it to "Images" (it's case sensitive right now so don't forget the highercase "I") and you'll see all the files within the "Images" directory.

To be able to move back one directory you just need to keep a variable (like OldDirectory$) to store the last directory before changing to the new one.

BytesFree is just a variable to store the space left on the drive. This can be made better by adding a new variable to store the hd size and make BytesFree = hd size then go through all files subtracting the file size of each file from the BytesFree variable.

If you have any questions ask away.
Wartorn
17
Years of Service
User Offline
Joined: 24th Oct 2006
Location: Molde, Norway
Posted: 7th Nov 2006 11:06
Ah, okay, cool!
I think i understand now, finally i can make some progress again
Thanks alot! Owe you one
Wartorn
17
Years of Service
User Offline
Joined: 24th Oct 2006
Location: Molde, Norway
Posted: 7th Nov 2006 14:33
No.. wait.. i dont
Im still having trouble making a 3rd subdirectory

like \Images\Old\Bmp\EvenAfourthOne

if you know what i mean.. i still can only access a certain amount

Login to post a reply

Server time is: 2024-09-25 11:29:16
Your offset time is: 2024-09-25 11:29:16