Originally posted by David Harrison
I'm using a piece of code in a translate to parse a fixed length left justified field and replace a leading 'A' (if it exists) with 'AA'.
>A123456 < should translate to >AA123456 <
This fails occasionally although I can't reproduce it using the test tool. The error I've seen is:
>232595 < comes out as > <
My code is:
######################################################################
# Name: XltAtoAE
# Purpose: Change PAS A number to AA.
#
# UPoC type: xltp
# Args: none
# Notes: All data is presented through special variables. The initial
# upvar in this proc provides access to the required variables.
#
# This proc style only works when called from a code fragment
# within an XLT.
#
# v1 DTH 03/12/03 Initial Version, for PAS to Telepath.
# v2 DTH 22/02/05 To change 'A' to 'AA'
proc XltAtoAE {} {
upvar xlateInVals xlateInVals
xlateOutVals xlateOutVals
set x [lindex $xlateInVals 0]
switch $x
"" {}
"default" {regsub "A" $x "AA" y; set xlateOutVals
}}Any suggestions for improvement would be appreciated.Thanks,Dave