Here we use Output Monitors to solve the problem of finding the most recent file in a directory. In this example, we want to find the most recently changed file in the c:\builds\source directory. This DOS command lists the files in order from oldest to newest: "dir /b /od /a-d c:\builds\source\.** ".
The output is as follows:
LOGOSTRS.PAS
LOGOMAIN.PAS
ABOUT.PAS
hello.pas
BBXAbt.pas
bbxmain.pas
ttree.pas
logging.pas
servtest.pas
Thus, we use an Output Monitor to retrieve the last line of the output.
First, create a variable to hold the name of the most recent file. Call it "filename".
Click "Add a New Output Monitor" then set the options as shown:
The Search String defines what lines of text are selected. In this case, we don't care what the text is - we just want the last one. So the *, combined with Use Wildcards matches any text.
The Behaviour lets you choose options like failing if the text doesn't match. The Save Last Match to Variable option is obviously the appropriate one here.
The final result looks like this: