Call stand alone proc in a tps proc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Call stand alone proc in a tps proc

  • Creator
    Topic
  • #52647
    Rick Pritchett
    Participant

      How would i call a stand alone tcl proc inside a tps proc and use the value returned by the stand alone proc in the tps proc?

    Viewing 4 reply threads
    • Author
      Replies
      • #74977
        Jim Kosloskey
        Participant

          Rickey,

          By standalone do you mean a command line proc or simply another tcl proc which is designed to be invoked by other tcl procs?

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

        • #74978
          Rick Pritchett
          Participant

            command line.

          • #74979
            Jim Kosloskey
            Participant

              Rickey,

              OK I think you use the system command rather than the exec (or it could be the other way around) in order to get the exit value a command line proc returns.

              I would use a catch and inside that a set ret_val [exec (or system) yourproc any switches].

              Something like the above.

              Just be aware whichever (system or exec) waits for the result to be returned you will have probably blocked the entire integration process to which the thread belongs until the command line proc is finished.

              That might not be desirable especially if the command line proc’s work could be lengthy.

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

            • #74980
              Rick Pritchett
              Participant

                here is the proc

                set arg_values $argv

                set SERVER [lindex $arg_values 0]

              • #74981
                David Barr
                Participant

                  I would modify your script to put it in a proc.  

                  proc database_call { args } {

                   set arg_values $args

                  set SERVER [lindex $arg_values 0]

                            set DATA_BASE_ENTRY [lindex $arg_values 1]

                            set USER [lindex $arg_values 2]

                  ...

                  # don't echo the value from within your proc. it isn't necessary.

                  #echo $VALUE

                  ...



                              odbc SQLFreeHandle SQL_HANDLE_ENV $henv

                             

                              #echo hello



                    return $VALUE

                  }



                  echo [database_call $argv]

                  The last “echo” line is only for when you are calling this script from the shell. If you only call it from TCL, then this is unnecessary.

                  You can either put this in your TCL auto_path directory (and run mktclindex in that directory) or you can put “source /path/to/script/database_call.tcl” in the TPS proc before you call it.

                  To call the proc, you should be able to say:

                  set value2 [database_call “SERVER” “INI ENTRY” “user” “pword” “Accident” “description” “Illness”” “code”]

                  You’re also better off listing the argument names in your proc definition. The use of the word “args” as a parameter is special and is not how you should normally write procs.

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