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 Discussion / Another Question by Me.

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 1st Sep 2005 17:51
How would I go about making it so you can browse in a folder for a specific filetype? And with Sven B's textbutton thing, You can click on it and add it to a list?

I'm expecting my bud TDK to be here, showing off his answers and then Sven B and Nanobrain rub it off in my face J/K... Hahaha.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 1st Sep 2005 17:56
Ok... I'll wait till TDK answered.

Immunity and Annihalation makes Immunihalation...
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 1st Sep 2005 17:57
Hahaha, no its ok, I see your good with browser windows
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 1st Sep 2005 18:02
Oh- and how would you have your own Icon for an exe instead of that silly glass thing?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 1st Sep 2005 18:44
Ok then. A quick tutorial:

I think you know the basics:

get dir$() is the current directory
perform checklist for files makes a list of files in the current directory
find first finds the first file in the directory.
find next finds the next file in the directory.

get file name$() returns the filename
get file type() returns the file type

Well, I think this is all the commands we need...

First we start with the perform checklist for files command.
Since it has to be done once, we do it before the loop. Also the checklist quantity() has to be done once, so also before the loop and we store it in the variable cq. (The current directory is the one where the file is)



Next, we have to add the buttons and the list of all files in the directory:
To add the buttons it's pretty handy to use a function.
And I think you're pretty familiar with the code, so I didn't comment it:


To display the list, we're probably going to need find first, find next and get file name$().

The back button is standard the second file in the list. (Find first : find next)



Note that the 'scrolly' variable will have to decrement for going up, and increment for going down (scrolling).

Ofcourse, buttons are pretty useless when they don't do anything. So we're using the cd (change dir) command to change the current directory, get file type() to check if the file is a directory or not and ofcourse, the well known perfom checklist for files and checklist quantity() will be a part of the code.

To configure the 'back' buttons, we'll first have to check if the file is directory. (This value also changes to 'not' when the directory is a drive, wich will be very handy). If so, we change the directory (cd) and perform again a checklist + check number of items.

So it becomes:


This can also be adapted to the list:



Now you can freely browse through windows.

The whole code:


Ofcourse, you can change the scrolly value too, wich will cause the scrolling effect.
For example:

using up/downkeys



Or the scrollwheel:



That all for the browsing.

Next: the list.

Arrays are probably the easiest way to create a list. So that's also exactly what we're going to use:



When adding an items, we simply increase 'nrofffiles' and put the data in the array list$().



Press enter and you'll see all data that is stored in the array list$().

Next, we have to search for the extension of the file.
For example, we only have to be able to click mp3's, wich have the extension: '.mp3' and has 4 characters.
These 4 characters always come AFTER the file name. So it's easy to find them:


Now we have found the extension. To be sure it's spelled in lowercase, we add the function lower$().

When adding this to our browser:
Try clicking on a couple of mp3's and other files. Then press enter.


That concludes the tutorial for now.

I hope it helped,

Sven B

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 1st Sep 2005 19:11 Edited at: 1st Sep 2005 19:12
Quote: "Ok then. A quick tutorial:"

Quick??

Hate to see a long tutorial

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 1st Sep 2005 19:24
Shorter? ok :

To make a browser:



To add a list you use this code:


And to get the extension:



That concludes the tutorial.

I hope it helped,



Immunity and Annihalation makes Immunihalation...
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 1st Sep 2005 21:28
Hehe, yeah, of course it helped!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Sep 2005 18:35 Edited at: 10th Sep 2005 06:19
Lol!

Unfortunately, occasionally I have to sleep - knowing full well I'm leaving you in the capable hands of Sven and Nanobrain!

Besides, I've already posted my FileSelector program in another thread...

http://forum.thegamecreators.com/?m=forum_view&t=59002&b=10



TDK_Man

blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 12th Dec 2005 09:00
Quote: "Get file type$()"


AAAARRGHh! Stupid blanky.

I was extracting a handful of rightmost letters from the filename...
....then again, I'm only allowing for one file type anyway (specific browser for a level editor)

16-colour PNGs pwn.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Dec 2005 20:00
Old, old. Soo old...

Man, this thread was started ages ago. BTW Blanky, isn't it "get file type()" and it returns a value for folder/empty folder/file? I don't think there is a command for returning the extension...

Immunity and Annihalation makes Immunihalation...
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Dec 2005 22:02
Quote: "Unfortunately, occasionally I have to sleep - knowing full well I'm leaving you in the capable hands of Sven and Nanobrain! "


How can you tell he's Nanobrain? When people change their name I get so confused who's who.


UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 12th Dec 2005 23:03
Quote: "How can you tell he's Nanobrain? When people change their name I get so confused who's who. "

uh...Isn't nanobrain still called nanobrain?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 13th Dec 2005 20:34
Quote: "How can you tell he's Nanobrain? When people change their name I get so confused who's who."


The thread is from the time I, Nanobrain and TDK were very active on this forum, which gave us a good reputation...
Too bad I have to go to school, so I can't visit the forums as oftern as I used to...

Immunity and Annihalation makes Immunihalation...
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Dec 2005 07:34
@ UFO and Sven B

Ah ok.


Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Dec 2005 13:12
Yes there is. Search the forums.
new programmer
19
Years of Service
User Offline
Joined: 20th Dec 2005
Location: right behind you.
Posted: 22nd Dec 2005 05:31
nice, i hate those glass boxes anyway, i hate searching the forums, if any1 finds something post it here lol

Login to post a reply

Server time is: 2025-05-22 22:31:14
Your offset time is: 2025-05-22 22:31:14