- This wiki is out of date, use the continuation of this wiki instead
Glob
From FenixWiki
(Difference between revisions)
Revision as of 15:24, 22 April 2007 (edit) Woody (Talk | contribs) ← Previous diff |
Revision as of 14:11, 26 April 2007 (edit) (undo) Sandman (Talk | contribs) Next diff → |
||
Line 3: | Line 3: | ||
==Definition== | ==Definition== | ||
+ | '''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 | + | |
- | + | ||
== Parameters == | == Parameters == | ||
- | |||
{| | {| | ||
- | | '''STRING''' | + | | '''STRING''' criteria || - Search criteria: the folder in which you want to look, as well as any simple requirements for filenames such as extensions. |
|} | |} | ||
- | |||
== Returns == | == Returns == | ||
- | + | '''STRING''' : Filename | |
- | '''STRING''' : | + | {| |
+ | | "" || - No (new) file entries. | ||
+ | |- | ||
+ | | !"" || - The filename of a file entry matching the search criteria. | ||
+ | |} | ||
== Example == | == Example == | ||
- | |||
<pre> | <pre> | ||
- | + | 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 | ||
</pre> | </pre> | ||
+ | Both method result in the same, but the second one is less code. |
Revision as of 14:11, 26 April 2007
Contents |
Definition
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.
Parameters
STRING criteria | - Search criteria: the folder in which you want to look, as well as any simple requirements for filenames such as extensions. |
Returns
STRING : Filename
"" | - No (new) file entries. |
!"" | - The filename of a file entry matching the search criteria. |
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 method result in the same, but the second one is less code.