A `"run"' command

run@"run" macros The report writing programs described in previous sections can be given added flexibility through the use of macros (chapter [*]).

Consider the example in section [*] on page [*]. Suppose you wanted to generalize this report to print an arbitrary number of lines per person, and to report for only selected persons.

One way to do this would be to use two macros: "_count" and "_where". Then change line 3 of the report to  <"select from techs _where" and change line 12 to  <"while loop <_count"

Define these macros before running the report. For example,  <"macro _count = 10; macro _where = ' '"
"input forms" or  <"macro _count = 7;"
"macro _where = 'where position = "Tech 1"'"
"input forms"


You can make this operation much more friendly through the use of this "run" macro.[*] <"macro run = +"
"        'macro arg_1 = "' 2 '";' + "
"        'macro arg_2 = "' 3 '";' + "
"        'macro arg_3 = "' 4 '";' + "
"        'input ' 1"

Here is what happens when you type  <"run forms 5 'where position like "Tech*"' "

  1. The macro "arg_1" is defined to be `5'.
  2. The macro "arg_2" is defined to be `where position like "Tech*"'.
  3. The macro "arg_3" is undefined.
  4. The file `forms'[*] is input.

Of course, the report program on file "forms" must be aware of this "run" invocation. It should be written as follows.


*( data entry forms )
*( use is:  RUN filename count where_clause )
 
report
  select from techs   arg_2
    print
      1 1 id     i5
      1 10 name  a20
      4 10 'symbol    date    time   resistivity '
      5 1 ' '
    end print
 
    loop = 1
    while loop <=  arg_1
      print
        1 5 loop i2
        2 10 '------  --------  -----  ----------- '
      end print
      loop = loop + 1
    end while
    newpage
  end select
end report

to produce the output shown on page [*].

Reports|)