tcl argument question

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tcl argument question

  • Creator
    Topic
  • #51133
    Kevin Crist
    Participant

      We have a tclproc that we use that we put in arguments to change a field value. That works great, but i was under the impression i could put in another set of arguments but i doesnt recognize the second set. For example… {SEGMENT MSH}{FIELDNUM 8}{FIELDVAL MSH^A04}. That one works but i put this below and isnt recognized. {SEGMENT EVN} {FIELDNUM 1} {FIELDVAL A04}. I know this can all be set up easily in an xlate but in this case we dont have one, i was just seeing if i could add one more set of args. how do i set this up for multiple args. thanks for any ideas.

      #########################################################################################

      # Initialize Variables Used

      #########################################################################################

      set dispList

    • ;# Disposition List Returned to Engine

      set fldSep “” ;# Field Seperator – get from MSH

      set subSep “” ;# SubField Seperator – get from MSH

      set repSep “” ;# Repeating Field Seperator – get from MSH

      set SegName “” ;# User Supplied Segment to Change

      set FieldNum 0 ;# User Supplied Field Num to Change

      set FieldVal “” ;# User Supplied Value to set in Field Num

      set segList

    • ;# Message Segments in List Form

      set SegPos

    • ;# List of Seg Pos in segList that match

      ;#  the User Supplied Segment Name

      #########################################################################################

      # Load in the arguments we need that were passed from the caller

      #########################################################################################

      keylget args MODE mode             ;# The mode the engine called from

      keylget args ARGS.SEGMENT SegName ;# Segment Name

      set SegName [string toupper $SegName] ;# Force to uppercase

      keylget args ARGS.FIELDNUM FieldNum ;# Field Number to Change

      keylget args ARGS.FIELDVAL FieldVal ;# Value to Set Field To

      #########################################################################################

      # Switch based on what mode the engine was in when it called the procedure

      #########################################################################################

       switch -exact — $mode {

         run {

          set mh [keylget args MSGID] ;# Get message handle from args

         set dispList

        ;# Initialize to good message

             set msg [msgget $mh] ;# Get a copy of the message

             set fldSep [string index $msg 3] ;# Field Seperator

             set subSep [string index $msg 4] ;# Sub-Field Seperator

             set repSep [string index $msg 5] ;# Repeating Field Seperator

        set segList [split $msg r] ;# Split message into segList

        #########################################################################################

        # Validate the user supplied values

        #########################################################################################

        if { $SegName == “” } {

         echo n n

         echo “==========================================================”

          echo “:WARN – No Segement Name Was Supplied !”

         echo “:WARN – Message Continued As Is.”

         echo “:WARN – Here Is: $myname”

         echo “:WARN – Now Is: $nowis”

         echo $msg

         echo “==========================================================”  

         echo n n

               return $dispList

        }

        if { $FieldNum == “” || $FieldNum == 0 } {

         echo n n

         echo “==========================================================”

          echo “:WARN – Invalid or No Field Number Was Supplied !”

          echo “:WARN – Field Number is: “$FieldNum””

         echo “:WARN – Message Continued As Is.”

         echo “:WARN – Here Is: $myname”

         echo “:WARN – Now Is: $nowis”

         echo $msg

         echo “==========================================================”  

         echo n n

               return $dispList

        }

        #########################################################################################

        # Find Position of Segement(s) – If missing -> Continue Message and Return

        #########################################################################################

        set SegPos [lsearch -all -regexp $segList “^$SegName”]

        if { [lindex $SegPos 0] < 0 } {  echo n n  echo “==========================================================”   echo “:WARN – Segment “$SegName” Is Missing !”  echo “:WARN – Message Continued As Is.”  echo “:WARN – Here Is: $myname”  echo “:WARN – Now Is: $nowis”  echo $msg  echo “==========================================================”    echo n n        return $dispList } ######################################################################################### # Force the Segment/Field Value – Add Blank fields is Seg is too short. ######################################################################################### foreach Seg $SegPos { set fldList [split [lindex $segList $Seg] $fldSep] set fldCnt [llength $fldList] for { set flds $fldCnt } { $flds < [expr $FieldNum + 1] } { incr flds } {   lappend fldList {}   }     lset fldList $FieldNum $FieldVal     lset segList $Seg [join $fldList $fldSep]     } ######################################################################################### # Recreate the message and store back at msg handle #########################################################################################  set msg [join $segList r]        msgset $mh $msg } start { }    time { }    shutdown { }    default {     echo “:WARN”     echo “:WARN ======================================”  echo “:WARN – tps called with invalid mode !” echo “:WARN – Mode Is: $mode” echo “:WARN – Here Is: $myname” echo “:WARN – Now Is: $nowis” echo “:WARN ======================================” echo “:WARN”    } } ;# End Switch return $dispList } ;#

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