STx 3.9 Documentation

Up

Introducing File Items

Previous

Section Files

Next

XML Files

Status File

An S_TOOLS-STx status file item can be used to query the status of a file on disk, e.g. if it exists, when it was last modified etc. It cannot access the content of the file.

A status file item is created using the option /File.

Status File Example

The following script demonstrates the use of a status file item.

[macro status_file_example] readvar #argv #filePath // // create the status file item // #f := new file * /File if '$#f[?]' != 'file' then em -1 ; '$#mac - Failed to create the status file item' end // // interpret #argv parameter as a file path or ask user to choose // a demonstration file // if '$#filePath' == '' then butil 'FileDialog open ; Select any file' #filePath := set $result if '$#filePath' == '' exit end // // check file exists // $#f status $#filePath if '$rc' != 0 em $rc ; 'msgbox msg ; "$#filePath" does not exist' butil 'msgbox msg ; The file "$#filePath" exists' // // display last modification date/time // readstr '$#f[!modified]' #date #time butil 'msgbox msg ; Last modified on $#date at $#time' // // ask user if they want to delete the file // butil 'msgbox yesno ; Delete "$#filePath" from disk?' if '$result' == 'yes' $#f delete $#filePath // // delete the status file item (not the file) // delete $#f exit

© 2009 The Austrian Academy of Sciences Acoustics Research Institute