File name (amending first 3 characters)

Clovertech Forums Cloverleaf File name (amending first 3 characters)

  • Creator
    Topic
  • #122562
    bso its
    Participant

      Hi

      I have a script : to remove the characters WBS and replace with NIBTS

      proc set_outbound_name {args} {

      # Extract MODE safely
      if {[catch {keylget args MODE mode}]} {
      return “”
      }

      # ✅ Ignore startup call
      if {$mode eq “start”} {
      return “”
      }

      # Extract MSGID and ARGS safely
      if {[catch {keylget args MSGID msgid}]} {
      return “”
      }

      if {[catch {keylget args ARGS innerArgs}]} {
      set innerArgs {}
      }

      # ✅ Get driverControl (this is where FILENAME lives)
      set driverControl [msgget $msgid]

      # Extract filename from driverControl list
      if {[catch {keylget driverControl FILENAME fname}]} {
      return

        }

        set base [file tail $fname]

        # DEBUG (leave enabled for now)
        HciAlert -info “FINAL DEBUG: original filename = $fname”

        if {[string match “WBS*” $base]} {

        regsub {^WBS} $base “NIBTS” newbase

        set dir [file dirname $fname]
        set newfname [file join $dir $newbase]

        # ✅ Write back into driverControl
        keylset driverControl FILENAME $newfname

        # ✅ Save updated driverControl
        msgset $msgid $driverControl

        HciAlert -info “FINAL DEBUG: new filename = $newfname”
        }

        return

           

          But it doesnt work  -Any advice ?

          Thanks in advance

        Viewing 3 reply threads
        • Author
          Replies
          • #122563
            Jason Russell
            Participant

              I don’t see anything particularly wrong with the code. How is it not working? What is the echo of the $base going in and the $newbase coming out?

            • #122567
              Jim Kosloskey
              Participant

                Don’t you need to do a msgmetaget in order to get the DRIVERCONTROL keyed list?

                email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

              • #122568
                Jason Russell
                Participant

                  I missed that. You’re correct:

                  set myklst [msgmetaget $mh DRIVERCTL]
                  keylget myklst FILENAME fileName

                  Pretty sure I ganked that from another script before I understood keylget.

                • #122569
                  bso its
                  Participant

                    Thank you for the replies (much appreciated)

                    Will make amends and let you know.

                    The issue is that its not attaching the “new” file name so its failing by saying file name is blank

                    Thanks again

                Viewing 3 reply threads
                • You must be logged in to reply to this topic.