how to ignore a field if it isnt thier in tcl

Clovertech Forums Read Only Archives Cloverleaf Tcl Library how to ignore a field if it isnt thier in tcl

  • Creator
    Topic
  • #51307
    Kevin Crist
    Participant

      The following code finds the phone number and fixes. It works fine with one exception, when we have an adt like an A28, or A31 come through, sometimes they dont have much info in them and if the PID segment doesnt fill out to reach the phone number field it errors the message out.

      How do i fix this so if there is no field it doesnt error it out? Thanks for any thoughts.

       set PIDList [split [lindex $segList $PIDpos] $fldSep]

       set phone [lindex $PIDList $PIDphone]

       if { [string index $phone 0] == “(” } {

           set phone [string range $phone 0 12]

       } else {

          set phone “”

       }

       lset PIDList $PIDphone $phone

    Viewing 0 reply threads
    • Author
      Replies
      • #69626

        You could try …

        Code:

        set PIDList [split [lindex $segList $PIDpos] $fldSep]
        set phone [lindex $PIDList $PIDphone]
        if {$phone ne “”} {
        if { [string index $phone 0] == “(” } {
            set phone [string range $phone 0 12]
        } else {
           set phone “”
        }
        lset PIDList $PIDphone $phone
        }

        -- Max Drown (Infor)

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