I’ve been working on an irritating issue for the past couple of days. I’ve set up a fileset-local thread to watch a folder containing multiple files. The first issue I ran into was needing a Directory Parse routine. One of my team mates found the following proc:
######################################################################
# Name: tps_pmm_dir_parse
# 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 tps_pmm_dir_parse { 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 Item.Dat}
# 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 process 1
set pattern CPM.RCV.clean
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
}
}
}
if { [info exists out_list] } {
echo “nn HERE IS WHAT WE SHOULD PROCESS:t $out_list”
msgset $mh $out_list
return “{CONTINUE $mh}”
}
msgset $mh “”
return “{CONTINUE $mh}”
}
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”
}
}
}
The file I am trying to process is a FRL looking like:
1 276250PC 00000002382503 7117021 2 EAN
2 276250PC 0000000245776 7117021 1 EAN
3 276250PC 0000000245776 7117021 1 EAN
4 276250PC 0000000245776 7117021 1 EAN
5 276250PC 00000008010154 7117021 1 EAN
6 276250PC 0000000803671 7117021 1 EAN
1 276251PC 0000000264644 7117021 1 EAN
2 276251PC 0000000804644 7117021 1 EAN
1 276263PC 507047 4962 7117021 3 EAN
1 276264PC 511018 8477 7117021 2 EAN
1 276265PC 511311 12102 7117021 1 BXN
1 276266PC 509531 2606 7117021 4 BXN
2 276266PC 509531 5634 7117021 1 EAN
1 276267PC 513878 14468 7117021 3 PKN
The Style option behaves as expected for EOF and single, but when I set it to nl, the results aren’t what I’m expecting. Even when the file I’m looking for isn’t present, a message is processed every 5 seconds. The message looks like:
{{MID {{DOMAIN 0 } {HUB 0 } {NUM 793103 }}} {SRCMID {{DOMAIN 0 } {HUB 0 } {NUM 793080 }}} {TYPE DATA } {SOURCECONN cpm_pic_i } {ORIGSOURCECONN cpm_pic_i } {DESTCONN 9 } {ORIGDESTCONN 9 } {TIME 1317246541} {PRIORITY 5120} {DATAFMT 0 } {SAVECONTEXT outbound} {OFFSET 1947201 } {LENGTH 76 } {FLAGS 0x408002} {STATE 14} {GROUPMID {{DOMAIN {}} {HUB {} } {NUM {} }}} {XLTTHREAD {} } {RETRIES 0 } {SKIPXLT 0} {USERECOVERDB 3} {GROUPID 0 } {TIMEIN 1317246540} {TIMEXLT 1317246541} {TIMEOUT 1317246541} {TIMEQCUR 0 } {TIMEQTOT 0 } {TIMEREC 1317246541} {TIMESTOR 0 } {TIMEARC 0 } {DBTABLE {} } {SEPCHARS 0 } {DRIVERCTL 65 } {USERDATA 0 }}
Thanks in advance for your time,
-Garrett