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.

Code Snippets / [DBP] - [MATRIX1] File Query

Author
Message
Chris Tate
DBPro Master
8
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 19th Jul 2015 22:01 Edited at: 14th Dec 2015 16:57
Most games and applications require data from the end user's harddrive; when developing such software in DBPRO, you may frequently need to lookup all of the files in a certain directory with a certain file extension, a feature which is not available in DBPRO's standard file querying commands.

This snippet can be used to query files by one or more extensions, and can limit the quantity of files permitted. It is used by first clearing any previous file query using ClearFileQuery(). The file query is then executed by supplying the folder path, comma seperated file extensions, and file count limit.

The snippet creates a list of files using an array called FileQuery(), which contains file names and extensions.
A folder path is required, and the command will not search sub folders. The file extensions need not be prefixed with a dot delimiter, but should. The extension query is actually a lookup of file names ending with the comma seperated parameters, therefore it could be used to search for more than just the file extensions. You can default the file count limit by passing a negative count such as -1; the default file limit is 99999999.

The snippet also contains handy file expressions such as IsImageFile() which checks the file extension for an image format, and GetFolder$() which returns the folder of a filepath.

After a filequery is complete, you should use ClearFileQuery() unless you wish to append addition files to the query.

+ Code Snippet

</div>

Login to post a reply

Server time is: 2017-07-22 03:54:14
Your offset time is: 2017-07-22 03:54:14