Contents Previous Next Subchapters

Listing the Names of Files in a Directory
Syntax listdir
listdir(directory)
listdir(directorypattern)
See Also dir , listdirs , exists , isdir , rmdir , findstr , find2

Description
Returns a character matrix containing a listing of the specified directory, where directory is a character row vector. If directory is not present, returns a listing of the current working directory. If the argument pattern is present, listdir returns only filenames that contain strings that match the Regular Expressions specified by the character row vector pattern.

Example
If the directory c:\omwin\programs contains the files edit.oms and TEST.OMS, and you enter
     listdir("c:\omwin\programs")
O-Matrix will respond
     edit.oms
     TEST.OMS
If you enter,
    listdir([OM_INSTALL,"\function"], "^fn.*")
O-Matrix will list only the functions in the function directory that start with the characters "fn".
    fn2cbp.oms   
    fn2clp.oms   
    fn2dbp.oms   
    fn2dlp.oms   
    fnbpole.oms  
    fnbut.oms    
    fncheb.oms   
    fncpole.oms  

Mlmode
In Mlmode , this function is called dir instead of listdir. If the directory C:\omwin\programs contains the files edit.oms and TEST.OMS, and in Mlmode you enter
     dir("c:\omwin\programs")
O-Matrix will respond
     edit.oms
     TEST.OMS