.key COM/A,PAT/A,DIR/A,OPT1,OPT2,OPT3,OPT4
.bra {
.ket }

; Wildcards for commands with no wildcard support
; Only the first argument can be a wildcard and the second one a directory

FailAt 21

IF EXISTS {DIR}
    List TO T:q{$$} {PAT} LFORMAT "{COM} *"%s%s*" *"{DIR}/%s*" {OPT1} {OPT2} {OPT3} {OPT4}"
Else
    List TO T:q{$$} {PAT} LFORMAT "{COM} *"%s%s*" *"{DIR}*" {OPT1} {OPT2} {OPT3} {OPT4}"
EndIF

IF NOT FAIL
    Execute T:q{$$}
Else
    Echo "{PAT} not found"
EndIF

Delete T:q{$$} QUIET >NIL:

FailAt 10
