Problem with xlt proc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Problem with xlt proc

  • Creator
    Topic
  • #47764
    David Harrison
    Participant

      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

    Viewing 0 reply threads
    • Author
      Replies
      • #56653
        Anonymous
        Participant

          It looks to me like the only way you could get a blank out is if the first subfield of what you’re passing in xlateInVals is empty.

          You might want to break down your switch statement to make it easier to read.  You don’t need to put it all on one line.  Take a look at the TPS template, it has a nice example of a switch statement.  I suspect that when you do that you may see where you haven’t accounted for all the possibilities.

      Viewing 0 reply threads
      • The forum ‘Cloverleaf’ is closed to new topics and replies.