Here is another proc you might find useful:
######################################################################
# Name: fset_ib_dirParse_regexp
# Purpose: Demonstrate the use of the directory parse tps
# within the fileset driver. This proc processes
# files matching or not matching a pattern
# the filenames specified in the configuration
# inbound read directory.
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (”start”, “run” or “test”)
# MSGID message handle
# ARGS PATTERN PROCESS
#
#
# Returns: tps disposition list:
# Returns a list of messages for the fileset
# driver to process.
#
proc fset_ib_dirParse_regexp { args } {
keylget args MODE mode ;# Fetch mode
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
keylget args CONTEXT ctx
#
# Check for correct context
#
if {![cequal $ctx “fileset_ibdirparse”]} {
echo “ERROR proc used in wrong context”
echo “Context should be fileset_ibdirparse”
echo “Proc called in: $ctx”
return “{CONTINUE $mh}”
}
# In this context what is handed to this proc
# by the driver is not a data message. Rather
# it is a space seperated string of file names
# from the directory the fileset driver is
# configured to read.
set ib_list [msgget $mh]
# This proc takes 2 user arguments. The first argument
# specifies a pattern to match against. The second
# argument tells the proc to either process all files
# in the directory matching the PATTERN value by passing
# a 1 as an argument, or to process all files in the directory
# except execpt those matching the PATTERN value by passing
# it a 0.
#
# For example to process all files in a directory containing
# the string foo you would pass this argument to this
# proc in the Directory Parst TPS:
# {PROCESS 1} {PATTERN foo}
# If you wanted to process all files execpt for a file named
# dummy pass this argument
# {PROCESS 0} {PATTERN dummy}
keylget args ARGS.PATTERN pattern
keylget args ARGS.PROCESS process
set out_list “”
if { ! $process } {
foreach i $ib_list {
if { ! [regexp — $pattern $i] } {
lappend out_list $i
}
}
} else {
foreach i $ib_list {
if { [regexp — $pattern $i] } {
lappend out_list $i
}
}
}
msgset $mh $out_list
lappend returnList “CONTINUE $mh”
return $returnList
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
default {
error “Unknown mode ‘$mode’ in fileset_dir_parse”
}
}
}