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 / How to make a checklist for certain types of files

Author
Message
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 3rd Oct 2012 07:17
Hello, basically I have a map editor, and when you load a map it will display a list of the ones you made. But the thing is I don't know how to use perform checklist for files for only one type-the map format- of data, if the user has a lot to have a scroll feature, and then how to select one from a list.

Thanks much.
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 3rd Oct 2012 10:17
Quote: "But the thing is I don't know how to use perform checklist for files for only one type-the map format- of data"

As far as I'm aware, there is no way to do this in the checklist commands. Instead, you need to handle this yourself. Below is a function and some example code that will return an array of file names of the correct type.



Quote: "if the user has a lot to have a scroll feature, and then how to select one from a list"

This is harder to answer simply because there are any number of ways of doing it. Generally a good starting point for scroll lists is to calculate how many lines will fit on the screen



and also to create a variable marking the top displayed item (by default 1).



Check for user inputs (depending on your scroll mechanism this will vary - for example checking the arrow keys or move movement on a scroll bar etc.) and use this to update the top item. So if the down arrow were pressed and there was still an overflow on the list



then increment the top item by 1



You can do the reverse to move up the list. You then need to use this data to display your list correctly. Generally, you want to loop through the visible items like this and display then as you please:



Finally for selecting an item from the list, that entirely depends on how your list works (is one selected at a time, do you need to click on the item etc.).

Anyhow I hope that helps. Do post again if you're still having trouble with this.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Oct 2012 12:41 Edited at: 3rd Oct 2012 12:42
I think STYX should help here...

This section in particular:

Quote: "
File Names and File Paths
A selection of commands to make working with files easier. Commands such as: Add/Remove Backslash, Change File Extensions, Expand Filename (turn the relative file name into a fully qualified path name by merging in the current drive and directory), Extraction commands to obtain the Drive, Extension, File Name and Path. There are also commands for Temp file handling, including the ability to create Temp Files that live in the Windows Temp folder.
"


Hope that helps...

EDIT

Highlighted key word...

Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 3rd Oct 2012 15:52 Edited at: 3rd Oct 2012 15:56
You can also use FIND FIRST and FIND NEXT to generate a list of files.

Here is a small example of what I do to scan a directory for BMP fiels.

EDIT: I don't use checklist anymore as it can only hold 255 items



The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 4th Oct 2012 03:28
Thanks Cybermind! that was helpful and I got my answerer. Thanks again!
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 4th Oct 2012 07:23 Edited at: 4th Oct 2012 07:38
Hey it's not working for some reason. I don't know what I must have done to it because it worked last time I loaded the project. basically it does not print any file (it still uses bmp because I'm still working on things) but as soon as I comment out the argument that only adds it if it's of a file type it will work fine, yes it prints ALL files, but that's not the point, here is the code, mostly unaltered at this point.

<----- = mycode



Thanks much

edit: weird if I fill the array before hand and comment out the same line as above it will print the text I put in it, yet if I unrem the " if lower$(right$ (filename$,3)) = "bmp" " it still prints blank and nothing is printed to the screen, even debug text that's outside the function right before the suspend for key. I have to admit I have no idea what I must have done...
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 4th Oct 2012 13:19
Do you have any bitmap files in your directory? I mean files with the extension .bmp, for that is what it checks for and will only fill array when it finds bmp files.

You can remove the 3 lines with cd ".." by the way, they just take you back if you changed directory.

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 4th Oct 2012 20:35
I do. But the weird thing seems to be around "if lower$(right$ (filename$,3)) = "bmp" "

For instance, if that and the code inside of it is remed. It will print "no data". Which is what I per-fill the array with.

If I just rem the argument and just let it full the array with the files, it will print all the files, and however many slots are left will print "no data".

However, if I rem the code inside the argument and not the argument, it will print blank. No text what so ever. Yet if I change the argument to anything other than "lower$(right$ (filename$,3)) = "bmp" " it will print fine. it will print "no data" but it prints.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 5th Oct 2012 13:59
Try to remove the cd "..", they just takes you 3 directories back and you don't need that if you dont change the directory earlier in the code. It should not be the problem but try anyway.

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 6th Oct 2012 06:04 Edited at: 6th Oct 2012 06:23
So any folder at that path by the name of "BMP" will show in his list and selecting it will probably cause the program to crash.

DB Pro is certainly no Java or .net when it comes to file handling.

But I would go the extra step and do this...



This will essentially 99.99% of the time test whether you have a file or a folder.

It will blacklist files with no extension as being a folder.
It will improperly think folders with periods in the name are files.
But these things are uncommon.


Oh yes and Windows will add thumbnail files "Thumbs.db" to any folder you navigate to with pictures. So black list that file as well.

Edit:
Pass to the function the file name itself without the file path for best results.

Edit Again:
I should mention that the checklist will list files and folders together, making it necessary to screen out folder names.


Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 6th Oct 2012 06:11
how do I add it?
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 6th Oct 2012 06:14 Edited at: 6th Oct 2012 06:25
The simplest way would be to empty the contents of the checklist into an array.
Screen the file names at this point.
Have the rest of your program work from the array instead of the checklist.

Quote: "I do. But the weird thing seems to be around "if lower$(right$ (filename$,3)) = "bmp" ""

Might be better instead wherever this line is... Just nest another IF Block inside of this one like:

if lower$(right$ (filename$,3)) = "bmp"
If ValidateFileName(filename$) = 1
`Stuff
EndIf
EndIf


Or just use an AND statement...

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 6th Oct 2012 06:35
the same thing is happening with you code, I think I must be dirtying it up somehow and not knowing it.

yah I did some experiments and for some reason when I comment sync on and sync rate 60 out. it works fine... so... yah. though how can I get something like that to work inside a 3d game if I cant use sync on?
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 6th Oct 2012 13:13
If he is unsure whether he gets a filename or not, I would do it like this: if lower$(right$ (filename$,4)) = ".bmp"

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 6th Oct 2012 17:48 Edited at: 6th Oct 2012 17:54
Quote: "If he is unsure whether he gets a filename or not, I would do it like this: if lower$(right$ (filename$,4)) = ".bmp""


That's a good idea. In this case since he's only dealing with one file type, that should be all that he needs.

In a situation where many file types are possible, then an appraoch like mine is more appropriate.

I would however recommend structuring the code like I have...



This will clean up the code and make it easy to do mass changes in the future if needed.

Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 8th Oct 2012 21:32
@Southside games: I use sync on and sync rate 60 :-P

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 11th Oct 2012 17:39
hey sorry about not replying, I've had a really busy last few days and could not get to my computer. Just wanted to say I got it working. Thanks for all your help!
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 14th Oct 2012 15:56 Edited at: 14th Oct 2012 15:57
U R most welcome, I am glad I could be of any help

EDIT: Just curious, in case I run in to the same problem. What made it work for you?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 14th Oct 2012 17:05
Really just made a 3d object. Like I said it would not print anything with "sync on" and "sync rate 60". So all I did was add the code to a 3d environment and it worked fine. Which is alright by me because I was going to use it in a 3d game anyway.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 14th Oct 2012 23:16
Okay I do, however, use it in an all 2D environment with no 3D functions. odd :-P

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 15th Oct 2012 06:08
not really. I'm pretty sure that it was me somehow.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Oct 2012 01:04
Quote: "EDIT: I don't use checklist anymore as it can only hold 255 items"

People have continued to claim this for years now. It's not true, as I've used checklists to read folders containing thousands of files.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Oct 2012 16:20
Quote: "not really. I'm pretty sure that it was me somehow"


I think so - but you also seem to have stumbled across a DBPro obscurity. You seem to have forgotten that you usually need to use the sync command when using sync on.

For some reason your original code worked in one case (with the "if" commented out) and not in the other. Might be something to do with the way DBPro triggers 3D rendering.

Anyway, this version of your code works both ways:

(I made a few other irrelevant changes to your code so I could see exactly what was being printed - blank text is hard to see )

Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 21st Oct 2012 19:29
Quote: "People have continued to claim this for years now. It's not true, as I've used checklists to read folders containing thousands of files."

This might be the reason why they do, taken from the help description for Checklist Quantity: "The checklist has a maximum storage capacity of 255 items"

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 29th Oct 2012 23:37
Is there a way I can check for a file? not Like an x or image or whatever. I mean a windows file that holds contents. Basically I want to add them to the list as well, so that way groups can be made.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Oct 2012 10:34 Edited at: 30th Oct 2012 10:56
A windows file that holds contents? I'm not sure what you mean. A zip or rar file?


Here's an open/save file dialog. I don't know who the original author was, but I've stripped this from my text editor challenge.



"You're not going crazy. You're going sane in a crazy world!" ~Tick
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 1st Nov 2012 06:17
I mean this. I looked at it in properties, but putting file in the check list does not add files in the result list.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Nov 2012 10:52
You mean a folder/directory?

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 2nd Nov 2012 03:32
yah. I though if I just said folder now one would get it.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Nov 2012 08:21
well its not a file, hence the confusion.

integer = get file type()
A value of zero indicates it is a file. A type value of 1 indicates it is a directory. A type value of -1 indicates there are no more files in the current working directory

"You're not going crazy. You're going sane in a crazy world!" ~Tick

Login to post a reply

Server time is: 2026-07-10 16:23:04
Your offset time is: 2026-07-10 16:23:04