Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COPY books from ZIP files.

Status
Not open for further replies.

webrabbit

MIS
Jan 31, 2003
1,059
US
Does anyone know of an integrated pre-compiler for Micro Focus COBOL that will extract the COPY books from ZIP archives?
 
I don't know of one, but this sounds like a really cool idea.

It should be fairly easy to write your own precompiler that executes pkzip on the command line to find the necessary copy book, extract it, and then let the compiler use it.

If you ever get something like this done, please let us know.

.DaviD.
 
1. Micro Focus COBOL supports multiple "integrated precompilers". This means that every input record read by the compiler is passed to the designated precompiler(s) and any number (including zero) of records can be passed back to the compiler. The compiler ships with a precompiler that handles the standard COBOL source code statements COPY, $IF, $ELSE, $END, DELETE, and INSERT. (Did I miss any? I have misplaced my COBOL Reference Guide.)

2. There are many sources of code/programs that can read a ZIP file.

I am looking for a precompiler that expands the (some) COPY statements from a ZIP file rather than standard DOS/Windows files. The name of the ZIP file(s) would be listed on the COBCPY path or after the IN or OF part of the COPY statement.
 
Doesn't the zipfolders shell-extension of WinXP work for you? This should enable automagic reading from zip files, but I never tested it, so can't tell about it :-(

HTH
TonHu
 
I think that shell extension only kicks in when you're using Wiudnows Explorer. It's as if it loading a Winzip app everytime you double click on a Zip file and then just showing you the contents in an explorer-style window.

But it brings up an interetsing question - anyone know if you can do a CD command into zip file (from DOS)? I don'y have XP here, so can't test.

.DaviD.
 
Hm, thats what I was afraid of.

I tried to CD into a zipfile, but that's not going to work.

I do recall that back in Win95 days (or maybe Win98) there was a ZipFolders (or named similarly) tool that allowed just that, a real extension to the filesystem. It required so much resources back then (about 48 MB or better if I recall....) that none of my available PC's could properly handle it, so I dropped it an forgot about it completely.
It is the product I found in this link: but I'm afraid it was pronounced dead several years ago.

HTH
TonHu
 
OTOH, I'd better advise to unzip all copybooks beforehand, as storage isn't very expensive these days. I drag around several thousand files in my projects (60% generated from a repository), and make occasional copies for a special build or new version-branch.

HTH
TonHu
 
The objective is not particularyly to save space, but to manage the COPY books more effectively. I have 28 gigabytes free on my hard disc.

I could write a program that would search the program to be compiled, extract the names of the copybook, run PKZIP from the command line, scan all the copybooks for COPY statements, and reiterate. But I was hoping for an itergrated approach

Thanks for all the input.
 
Actually, come to think of it, you could put all the copybooks in an lbr file and they would then be dirctly accessible provided the lbr was in a directory in the path and cobdir.

Assuming all your copy books are currently in the same directory you could do it in a bat file:

PACKCOPY.BAT
DIR *.cpy /B/O > BATCH.LBT
TYPE BATCH.LBT
RUN library BATCH.LBT = COPYCODE.LBR




Clive
 
Yes, I had forgotten about LBRs. And as I recall, the standard integrated precompiler fully supports LBRs. How about updating COPY books in LBRs. Is it easy to do? Can the Micro Focus editor do it?

Also, I archive all versions of my COPY books and source code in ZIP files. Would this be something that could easily be done with LBRs? And can current source code be stored in an LBR and compiled from there?
 
The MF interface to LBRs is kind of hokie. I wrote my own interface.

Code:
UNLBR.CBL
      ******************************************************************

       IDENTIFICATION DIVISION.

      ******************************************************************

       PROGRAM-ID.    UNLBR.
       AUTHOR.        CLIVE CUMMINS.
       INSTALLATION.  TUBULARITY.
       DATE-WRITTEN.  JUN 17,1995.

      ******************************************************************
      *      THIS PROGRAM WILL EXTRACT A FILE FROM A LIBRARY FILE.     *
      ******************************************************************

      ******************************************************************

       DATA DIVISION.

      ******************************************************************

      ******************************************************************
       WORKING-STORAGE SECTION.
      ******************************************************************

      ******************************************************************
       01  LBRMAN-PARAMETERS.
      ******************************************************************

           05  LBRMAN-FUNCTION                       PIC X    COMP-X.
               78  78-LBRMAN-CREATE-LBR    VALUE 1.
               78  78-LBRMAN-INCLUDE-FILE  VALUE 2.
               78  78-LBRMAN-UPDATE-LBR    VALUE 3.
               78  78-LBRMAN-CLOSE-LBR     VALUE 4.
               78  78-LBRMAN-LIST-CATALOG  VALUE 5.
               78  78-LBRMAN-FIRST-FILE    VALUE 6.
               78  78-LBRMAN-NEXT-FILE     VALUE 7.
               78  78-LBRMAN-DELETE-FILE   VALUE 8.
               78  78-LBRMAN-RENAME-FILE   VALUE 9.
               78  78-LBRMAN-HIDE-FILE     VALUE 10.
               78  78-LBRMAN-REVEAL-FILE   VALUE 11.
               78  78-LBRMAN-EXTRACT-FILE  VALUE 12.
           05  LBRMAN-FILE-NAME.
               10  LBRMAN-FILE-55                    PIC X(55).
               10  FILLER                            PIC X(200).
           05  LBRMAN-FILE-ATTRIBUTE                 PIC X    COMP-X.
               78  78-LBRMAN-SHOW-NORMAL   VALUE 0.
               78  78-LBRMAN-SHOW-HIDDEN   VALUE 1.
           05  LBRMAN-ATTRIBUTE-BYTE                 PIC X    COMP-X.
               78  78-LBRMAN-STANDARD      VALUE 0.
               78  78-LBRMAN-ENTRY-POINT   VALUE 1.
               78  78-LBRMAN-DELETED-ENTRY VALUE 2.
               78  78-LBRMAN-HIDDEN-ENTRY  VALUE 3.
           05  LBRMAN-TIME-BYTE                      PIC X(2) COMP-X.
           05  LBRMAN-DATE-BYTE                      PIC X(2) COMP-X.
           05  LBRMAN-SIZE-BYTE                      PIC 9(4) COMP-X.
           05  LBRMAN-ERROR-STATUS                   PIC X    COMP-X.
               78  78-LBRMAN-SUCCESSFUL    VALUE 0.
               78  78-LBRMAN-NO-LBR        VALUE 1.
               78  78-LBRMAN-EMPTY-LBR     VALUE 2.
               78  78-LBRMAN-INVALID-FILE  VALUE 3.
               78  78-LBRMAN-BAD-OPEN      VALUE 4.
               78  78-LBRMAN-BAD-CLOSE     VALUE 5.
               78  78-LBRMAN-BAD-READ      VALUE 6.
               78  78-LBRMAN-BAD-WRITE     VALUE 7.
               78  78-LBRMAN-BAD-LOAD      VALUE 8.
               78  78-LBRMAN-BAD-LBR-WRITE VALUE 9.
               78  78-LBRMAN-NO-MATCH      VALUE 10.
               78  78-LBRMAN-BAD-CATALOG   VALUE 255.
           05  LBRMAN-NEW-FILE-NAME.
               10  LBRMAN-NEW-FILE-55                PIC X(55).
               10  FILLER                            PIC X(200).

      ******************************************************************

       PROCEDURE DIVISION.

      ******************************************************************

           INITIALIZE LBRMAN-PARAMETERS.
           ACCEPT LBRMAN-FILE-NAME FROM COMMAND-LINE.
           IF LBRMAN-FILE-NAME EQUAL SPACES
               DISPLAY 'ENTER x:\path\lbrname.LBR\filename '
               ACCEPT  LBRMAN-FILE-NAME.
           MOVE 78-LBRMAN-EXTRACT-FILE  TO LBRMAN-FUNCTION.
           CALL 'LBRMAN' USING LBRMAN-PARAMETERS.
           IF LBRMAN-ERROR-STATUS EQUAL 78-LBRMAN-SUCCESSFUL
               DISPLAY LBRMAN-FILE-NAME
               DISPLAY 'HAS BEEN EXTRACTED'
           ELSE
               DISPLAY LBRMAN-FILE-NAME
               DISPLAY 'NOT FOUND'.
           GOBACK.

I don't see any reason why you couldn't do the same thing with source. You just need to refer to the lbr files thus:
c:\mysrc.lbr\myprog.cbl and
c:\mycpy.lbr\mycopy.cpy (if in a different LBR)

Extracting with my program only creates an external copy so the extracted test version could be called ahead of the prod version in the LBR when testing.

If you decide to put GNTs in an LBR you may need to use the -L6 runtime switch to stop the runtime looking in the LBR first. In this way test GNTs could run ahead of the LBR GNTs. In the animator the LBR GNTs would just zoom.

I have several bat files that automate these procedures if you want them. They enable you to Compile, put in lbr and create a CFG and EXE, for multiple programs all in one step.

The build method is far better than linking and enables you to ship fewer runtime files.

Hope this helps.


Clive
 
Thank you Clive, but I want to read the file into memory, not extract it to disc.
 
In most cases you are right. But sometimes I would like to put a miscelaneous set of configurations files in a location where I can easily read it but the user cannot easily see or modify it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top