This wiki is out of date, use the continuation of this wiki instead

Glob

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 18:11, 30 April 2007 (edit)
Woody (Talk | contribs)
(Example - I can't compete with dtuch efficiency)
← Previous diff
Revision as of 00:52, 1 May 2007 (edit) (undo)
Woody (Talk | contribs)

Next diff →
Line 26: Line 26:
String filename; String filename;
Begin 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: // method two:
Line 34: Line 46:
End End
</pre> </pre>
 +Both methods result in the same, but the second one is less code.

Revision as of 00:52, 1 May 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 methods result in the same, but the second one is less code.

Personal tools