USE statement

Hans Hendriks hans@robelle.com
Tue, 23 Jun 1998 12:08:31 -0700


David Maclary ( dmaclary@wellmanage.com ) asks:

> > The USE statement in PowerHouse is limited in that it is it's own
> > statement, and therefore can not be used within other statements, like
> > report groups, etc.  What this means is that code can not be
> written once
> > and reused "anywhere", which reduces code reusability and increases
> > program maintenance.
> >
> > For instance, in Quiz, I can...
> >
> > USE FILE.GROUP
> >      ITEM5 &
> >      ITEM6
> >
> > Where FILE.GROUP contains...
> >
> > REPORT &
> >     ITEM1 &
> >     ITEM2 &
> >
> > But, what would really be useful, is to be able to...
> >
> > REPORT &
> >     ITEM1 &
> >     ITEM2 &
> > USE FILE2.GROUP2
> >     ITEM5 &
> >     ITEM6
> >
> > where FILE2.GROUP2 contains code that I want to reuse in a number of
> > places, and the code before and after the USE changes.
> >
> > One workaround that I'm experimenting with is to use VESOFT's STREAMX
> > program, which does not have the PowerHouse limitation.  The problem is
> > that I'd have to replace all PowerHouse USEs with STREAMX USEs and do a
> > prepass on all reports with STREAMX before running them.  Here is the
> > command file so far...
> >
> > PARM STRMXIN,STRMXOUT
> > FILE STRMFILE=!STRMXIN
> > FILE STRMSAVE=!STRMXOUT;REC=-80,,F,ASCII;DISC=999999
> > IF FINFO("!STRMXOUT","EXISTS") THEN
> >    PURGE !STRMXOUT
> > ENDIF
> > ERRCLEAR
> > RUN STREAMX.PUB.VESOFT;PARM=%441 > STRMXOUT
> > IF HPCIERR <> 0 THEN
> >    PRINT STRMXOUT;PAGE=0
> > ELSE
> >    PRINT !STRMXOUT
> > ENDIF
> > RESET STRMFILE
> > RESET STRMSAVE
> >
> > The input file would look like...
> >
> > REPORT &
> >     ITEM1 &
> >     ITEM2 &
> > ::USE FILE2.GROUP2
> >     ITEM5 &
> >     ITEM6
> >
> > Has anyone else come up with workarounds to this problem?  If
> so, I'd like
> > to hear them !!!

Our <plug> Qedit </plug> editor has a feature for listing "included" files
that you could "use" :-)

Qedit's LIST command accepts a "$use" option, which will search any use
files referenced by a source file when listing strings or line ranges. (It
also has a "$include" option for COBOL include files). For example, lets say
you have 3 use files:

USE1
-------
  Here is the first line of the program
  here is another line
  use use2
  second last line of use1
  last line, all done

USE2
-------
  *****************************
  here is a line in USE2
  ...and another line in USE2
  use use3
  Last Line in USE2
  ******************************

USE3
-------
  ++++++++++USE3!!!++++++++++++++++
  here is a second-level nested use file
  ++++++++++++++++++++++++++++++++

... when you do a "listq $use USE1", you'll see: (My comments at right)

  Here is the first line of the program       <<<< first line of USE1
  here is another line
  use use2                                     <<<< reference to USE2
  USE use2                                    <<<< Inverse highlighted
  *****************************          <<<< First line of USE2
  here is a line in USE2
  ...and another line in USE2
  use use3                                      <<<< Reference to USE3
  USE use3                                     <<<< Inverse highlighted
  ++++++++++USE3!!!+++++++++++++++  <<<< first line of USE3
   here is a second-level nested use file
  ++++++++++++++++++++++++++++++++
  end $include                                 <<<< Inverse highlighted (end
of USE3)
  Last Line in USE2
  ******************************
  end $include                                 <<<< inverse highlighted (end
of USE2)
  second last line of use1
  last line, all done

It's quite easy to package this into a command file as follows:

USEQUIZ.CMD
===========
parm sourcefile
continue
purge quizuse,temp
/listq $use !sourcefile > quizuse   {list sourcefile, expanding referenced
files}
/text quizuse
/deleteq "&dB"   {delete lines with inverse hilite}
/deleteq "~use@"(pattern) {delete redundant use file references}
/keep,yes
quiz

Advantages over STREAMX?:
- No editing required for existing use file references
- handles "nested" use files.

Hope this makes sense .....

/Hans
|----------------------------------------------------------------------
| Hans Hendriks       Robelle Consulting
| http://www.robelle.com/~hans
| hans@robelle.com    personal:hans@cheerful.com

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
powerh-l@lists.swau.edu is gatewayed one-way to bit.listserv.powerh-l
This list is closed, thus to post to the list, you must be a subscriber.