- This wiki is out of date, use the continuation of this wiki instead
Glob
From FenixWiki
(Difference between revisions)
Revision as of 00:52, 1 May 2007 (edit) Woody (Talk | contribs) ← Previous diff |
Revision as of 22:43, 16 June 2007 (edit) (undo) Sandman (Talk | contribs) m Next diff → |
||
Line 5: | Line 5: | ||
'''INT''' glob ( <'''STRING''' criteria> ) | '''INT''' glob ( <'''STRING''' criteria> ) | ||
- | Gets a single filename matching the criteria and keeps returning new ones on subsequent calls until it can't find any more, in which case it returns "". To restart the search, a call to [[frame]]() is needed, in which case frame(0); can come in handy. | + | Gets a single filename or directoryname matching the criteria and keeps returning new ones on subsequent calls until it can't find any more, in which case it returns "". To restart the search, a call to [[frame]]() is needed, in which case frame(0); can come in handy. |
== Parameters == | == Parameters == | ||
{| | {| | ||
- | | '''STRING''' criteria || - Search criteria: the folder in which you want to look, as well as any simple requirements for filenames such as extensions. | + | | '''STRING''' criteria || - Search criteria: the folder in which you want to look, as well as any simple requirements for filenames, such as extensions, and directory names. |
|} | |} | ||
== Returns == | == Returns == | ||
- | '''STRING''' : Filename | + | '''STRING''' : Filename or directoryname |
{| | {| | ||
- | | "" || - No (new) file entries. | + | | "" || - No (new) file/directory entries. |
|- | |- | ||
- | | !"" || - The | + | | !"" || - The name of a file/directory entry matching the search criteria. |
|} | |} | ||
+ | |||
+ | == Notes == | ||
+ | After a call to glob(), the global struct [[fileinfo]] is filled with information about the file/directory entry returned. | ||
== Example == | == Example == |
Revision as of 22:43, 16 June 2007
Contents |
Definition
INT glob ( <STRING criteria> )
Gets a single filename or directoryname matching the criteria and keeps returning new ones on subsequent calls until it can't find any more, in which case it returns "". To restart the search, a call to frame() is needed, in which case frame(0); can come in handy.
Parameters
STRING criteria | - Search criteria: the folder in which you want to look, as well as any simple requirements for filenames, such as extensions, and directory names. |
Returns
STRING : Filename or directoryname
"" | - No (new) file/directory entries. |
!"" | - The name of a file/directory entry matching the search criteria. |
Notes
After a call to glob(), the global struct fileinfo is filled with information about the file/directory entry returned.
Example
Program files; Private String filename; Begin // method one: Loop filename = Glob("levels\*.tul"); // Looks for a file in the relative folder // "levels" that has the file extension "tul". if(filename!="") load_level(filename); // load_level() would load the level file else Break; end End // method two: While( (filename = Glob("levels\*.tul")) != "" ) load_level(filename); End End
Both methods result in the same, but the second one is less code.