0

I was wondering if we have any TACL experts out there can can help me answer probably a very basic question.

How do you inject multiple arguments into you routine.

This is what I have currently so far

[#CASE [#ARGUMENT / VALUE job_id/number /minimum [min_job], maximum [max_job]/
                               otherwise]
   |1|#output Job Number = [job_id]
   |otherwise|
   #output Bad number - Must be a number between [min_job] & [max_job]
   #return
]

I have been told you need to use a second #ARGUMENT statement to get it to work but I have had no such luck getting it to work. And the PDF guides don't help to much.

Any ideas/answers would be great

Thanks.

Gizmo0
  • 13
  • 5

3 Answers3

1

The #CASE statement isn't required if your arguments are positional and of one type (i.e. you know what you are getting and in what order). In that case you can just use a sequence of #ARGUMENT statements to get the arguments.
In your example #ARGUMENT accepts either a number in a range or anything else - the OTHERWISE bit. The #CASE statement then tells you which of those two you got, 1 or 2.

#ARGUMENT can do data validation for you (you may recognize the output from some of the TACL routines that come with the operating system).

So you can write something like this:
SINK [#ARGUMENT / VALUE job_id/number /minimum [min_job], maximum [max_job]/]

The SINK just tosses away the expansion of the #ARGUMENT, you don't need it since you only accept a number and fail otherwise.

Andy Simpson
  • 367
  • 2
  • 6
  • Oh ok. I did try to do just an Argument before but I must of formatted it wrong as I kept getting an error. I may give it ago once I get the rest of my routine working to a point where it's doing what i want it to – Gizmo0 Jul 08 '20 at 20:37
0

I figured out a way but idk if it is the best way to do it.

It seems that for one an Argument statement needs to always be in a #CASE statement so all I basically did was mirror the above and just altered it for text rather than use integer.

If you know of any other/better ways let me know :)

Gizmo0
  • 13
  • 5
0

It find it best to use CASE when you have multiple types of argument input to process. Kind of mocked up how I would see multiple argument types being used in the context that you shared with the CASE expression:

?TACL ROUTINE

#FRAME

    #PUSH JOB_ID MIN_JOB MAX_JOB
    #SETMANY MIN_JOB MAX_JOB , 1 3
    [#DEF VALID_KEYWORDS TEXT |BODY| THISJOB THATJOB SOMEOTHERJOB]

    [#CASE
        [#ARGUMENT/VALUE JOB_ID/
            NUMBER/MINIMUM [MIN_JOB],MAXIMUM [MAX_JOB]/
            KEYWORD/WORDLIST [VALID_KEYWORDS]/
            STRING
            OTHERWISE
        ]
    | 1         |
        #OUTPUT VALID JOB NUMBER = [JOB_ID]
    | 2         |
        #OUTPUT VALID KEYWORD = [JOB_ID]
    | 3         |
        #OUTPUT VALID STRING = [JOB_ID]
    | OTHERWISE |
        #OUTPUT NOT A NUMBER, KEYWORD, OR A STRING
        #OUTPUT MUST BE ONE OF:
        #OUTPUT A NUMBER IN THE RANGE OF: [MIN_JOB] TO [MAX_JOB]
        #OUTPUT A KEYWORD IN THIS LIST: [VALID_KEYWORDS]
        #OUTPUT OR A STRING OF CHARACTERS
        #RETURN
    ]

    #OUTPUT
    #OUTPUT NOW WE ARE USING ARGUMENT [JOB_ID] !!!
    TIME

#UNFRAME