how do I pass args

Homepage Clovertech Forums Cloverleaf how do I pass args

  • Creator
    Topic
  • #113864
    Gene Millard
    Participant

    I have never passed args in tcl before.

    I would like to be able to do that.

    proc tpsTestProc {a {b 7} {c -2} } {

    expr $a / $b + $c

    }

    I am using the example from a tcl book.  It is passing args 6 and 3.

    Shows the answer should be 0.

    I am trying to use the testing tool in cloverleaf.

    I get this error

    0:TEST] Tcl error:
    msgId = message0
    proc = ‘tpsTestProc’
    args = ‘6 3’
    result = ‘wrong # args: should be “tpsTestProc a ?b? ?c?”‘
    errorInfo: ‘
    wrong # args: should be “tpsTestProc a ?b? ?c?”
    while executing
    “tpsTestProc {MSGID message0} {CONTEXT sms_ib_data} {ARGS {6 3}} {MODE run} {VERSION 3.0}”‘

    What is the proper way to enter the args in the Args box?

    I just put

    6 3

    Is there more that needs to be added to the code?

     

     

    The Guthrie Clinic
    Sayre, PA

Viewing 3 reply threads
  • Author
    Replies
    • #113865
      Jim Kosloskey
      Participant

      ARGS is a keyed list so you need to do something like this:

      keylget args ARGS

      Then $args will contain your arguments. Then you can use list commands to extract the actual values).

      I use arguments a lot in my procs and I prefer keyed list arguments versus positional arguments (like lists).

      So the ARGS Keyed list might look like this {ARGS {{ARG1 data} {ARG2 data} …}}.

      and I would use keylget arg1 ARGS.ARG1.

      That allows me to have the arguments keyword based.

       

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

    • #113866
      Gene Millard
      Participant

      So my proc line should look like this?

      proc tpsTestProc {ARGS {{ARG1} {ARG2} args} {

      The Guthrie Clinic
      Sayre, PA

    • #113867
      David Barr
      Participant

      No, it should look like this:

      proc tpsTestProc { args } {

      The easiest way to get started is to use the script editor in the IDE, start a new script, right click and insert a TPS proc from the template.

    • #113868
      Gene Millard
      Participant

      I have it working now.

      Thank you for your time.

      The Guthrie Clinic
      Sayre, PA

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10