Call a tps with arguments from within a tps

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library Call a tps with arguments from within a tps

  • Creator
    Topic
  • #50631
    Jerry Tilsley
    Participant

    Is it possible to make a call to another tps procedure (and pass arguments to it) from within a tps procedure?

Viewing 2 reply threads
  • Author
    Replies
    • #66844

      It certainly is!

      -- Max Drown (Infor)

    • #66845
      Jim Kosloskey
      Participant

      Here are the ways of which I am aware:

      Most common:

      Assume 2 procs proc1 (the invoking proc) and proc2 (the invoked proc).

      Assume arg1 and arg2 are the arguments from proc1 that proc 2 wants.

      In proc1 (assume proc 2 does not return anything):

      set arg1 “1st arg”

      set arg2 “2nd arg”

      proc2 $arg1 $arg2

      Proc 2 starts:

      proc proc2 {my_arg1 my_arg2} {……}

      In proc 1 (assume proc 2 does return something):

      set arg1 “1st arg”

      set arg2 “2nd arg”

      set stuff [proc2 $arg1 $arg2]

      Less common:

      In proc1:

      set arg1 “1st arg”

      set arg2 “2nd arg”

      proc2

      In Proc2:

      upvar $arg1 my_arg1

      upvar $arg2 my_arg2

      Also:

      In proc1:

      global arg1

      global arg2

      set arg1 “1st arg”

      set arg2 “2nd arg”

      proc2

      In proc2:

      global arg1

      global arg2

      There is also a differnt way if using namespaces/packages but I assume you do not want to go there right now.

      All of the above have some rules associated with them.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #66846
      Jerry Tilsley
      Participant

      Thanks!

      I was sure it could be done.  I have created a package before and used it with the package require command, but I was just wanting to use one proc and wanted to make sure I was thinking on the correct lines.

      Again, thanks for the assistance.

      Jerry

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

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10