out parameters in a proc

Clovertech Forums Read Only Archives Cloverleaf Tcl Library out parameters in a proc

  • Creator
    Topic
  • #49323
    Nate Kruse
    Participant

      New to Tcl, came from the PowerBuilder (PB) land.

      I did a search and didn’t see anything relevent…I’m trying to make a proc that has a few arguments.  Of the few arguments, one of them will be an “out” argument so I can return a value back to the original call and use the “out” value.  Basically, I am using the RETURN to give me one value, but I want more than one value returned to me.  I could probably RETURN an Array, but I want to know if my question is possible.

      proc do something {inItem inItem2 outMsg} {

      ….

      ….

      set outMsg “Testing this $inItem.”

      return 5;

      }

      Any thoughts?  We did this all the time in PB, but not getting good results with Tcl.

    Viewing 2 reply threads
    • Author
      Replies
      • #61505
        John Mercogliano
        Participant

          Read up on the upvar command this should do the trick for you.

          John Mercogliano
          Sentara Healthcare
          Hampton Roads, VA

        • #61506
          Michael Hertel
          Participant

            I would imagine you could also…

            set outMsg “Testing this $inItem.”

            return

              or even:

              set outMsg “Testing this phrase.”

              return

          • #61507
            Nate Kruse
            Participant

              Thanks for the responses.  I’ll take a look at both options.

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