× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm trying to extract the Print Data of a *USERASCII spool file using
QSPGETSP.   
From what I can tell I have everything setup correctly. I'm using the
SPFR0200 format. I have 3 data structures setup pointing at the user
space. One for the Generic Heading information, one for the buffer
information, and one for the general information. I'm able to loop
through the user space and increment my pointers based on the offset
info and length of the buffer information, but the problem I'm having is
figuring out what I need to do to extract the print data/text from the
spool file. Right now I'm adding the print data offset of the buffer to
the pointer of the user space and using the %Str BIF with a length of
the print data size. I don't know if that's correct, but I figured I'd
start trying that way. The way I'm doing it is not producing anything.
(ie WorkString is always blank). I suspect I'm not setting my pointers
correctly, and I'm not sure what they need to be set to. Can anyone tell
me what I need to do to correct this?
Ultimately I want the WorkString field to contain the ASCII print data
from the spool file.
I'll post the code that I have. I did not include the code where I
create the user space and the error handling code in order to keep size
of this post as small as possible.

 
//*******************************************************************
     //Generic Header

 
//------------------------------------------------------------------- 
     D p_UsrSpc        s               *
     D dsGH            DS                   BASED(p_UsrSpc)
     D                                     qualified
     D UserData                1     64
     D*                                             User Data
     D HeadSize               65     68B 0
     D*                                             Header Size
     D StructLevel            69     72
     D*                                             Struc Level
     D SplFileLevel           73     78
     D*                                             Spooled File Level
     D FormatName             79     86
     D*                                             Format Name
     D InfoComp               87     87
     D*                                             Info Complete Ind
     D Reserved1              88     88
     D*                                             Reserved1
     D UseSpacUsed            89     92B 0
     D*                                             User Space Used
     D OffFrstBuff            93     96B 0
     D*                                             Offset First Buffer
     D BuffReqsted            97    100B 0
     D*                                             Buffers Requested
     D BuffRetrned           101    104B 0
     D*                                             Buffers Returned
     D SizePrtData           105    108B 0
     D*                                             Size Print Data300
     D NumCompPage           109    112B 0
     D*                                             Nbr Comp Pages
     D FrstPageNum           113    116B 0
     D*                                             First Page Nbr
     D OffFrstPage           117    120B 0
     D*                                             Offset First Page
     D Reserved2             121    128
     D*                                             Reserved2
 
//-----------------------------------------------------------------

 
//*******************************************************************
      // Buffer Information
 
//-------------------------------------------------------------------
     D p_Buffer        s               *
     D dsBuffer        DS                   BASED(p_Buffer)
     D                                     qualified
     D LenBuffInfo             1      4B 0
     D*                                             Length Buffer Info
     D BuffName                5      8B 0
     D*                                             Buffer Number
     D OffGenInfo              9     12B 0
     D*                                             Offset General Info
     D SizeGenInfo            13     16B 0
     D*                                             Size General Info
     D OffPageData            17     20B 0
     D*                                             Offset Page Data
     D SizePageData           21     24B 0
     D*                                             Size Page Data
     D NumPageEntry           25     28B 0
     D*                                             Number Page Entries
     D SizePageEntry          29     32B 0
     D*                                             Size Page Entry
     D OffPrintData           33     36B 0
     D*                                             Offset Print Data
     D SizePrintData          37     40B 0
     D*                                             Size Print Data
 
//------------------------------------------------------------------

 
//*******************************************************************
      // General Information
 
//-------------------------------------------------------------------
     D p_general       S               *
     D dsGeneral       DS                  Based(p_general)
     D                                     qualified
     D NumNonBlankLn           1      4B 0
     D*                                             Nbr Nonblank Lines
     D NonBlankLinPg1          5      8B 0
     D*                                             Nonblank Lines Page1
     D ErrBuffNum              9     12B 0
     D*                                             Error Buffer Number
     D OffErrRecovry          13     16B 0
     D*                                             Offset Error
Recovery
     D PrintDataSize          17     20B 0
     D*                                             Print Data Size
     D SplState               21     30
     D*                                             State
     D LstPageCont            31     31
     D*                                             Last Page Continues
     D AdvPrintFunc           32     32
     D*                                             Advanced Print Func
     D LacArryInBuff          33     33
     D*                                             LAC Array in Buffer
     D LacInAnyBuff           34     34
     D*                                             LAC in Any Buffer
     D LacInErrInfo           35     35
     D*                                             LAC in Error Info
     D ErrRecovryInfo         36     36
     D*                                             Error Recovery Info
     D ZeroPages              37     37
     D*                                             Zero Pages
     D LoadFont               38     38
     D*                                             Load Font
     D IPDSData               39     39
     D*                                             IPDS Data
     D Reserved               40     44
     D*                                             Reserved
 
//------------------------------------------------------------------

     D SpoolBuff       S             10I 0
     D sf              s             10I 0
     D
     D WorkString      S           5000A   Varying
     D pData           S               *
      /Free

        // Read Sequentially starting at first buffer
        SpoolBuff = -1;

        // Open Spoolfile
        QSPOPNSP(SpoolHandle :
                 QualName    :
                 ' '         :
                 ' '         :
                 eSpoolName  :
                 eSpoolNumber:
                 SpoolBuff   :
                 QUSEC);

        // Get Spoolfile and return to user space
        QSPGETSP(SpoolHandle:
                 MySpace    :
                 'SPFR0200' :
                 SpoolBuff  :
                 '*WAIT'    :
                 QUSEC);

        // Get pointer to user space
        QUSPTRUS(MYSPACE: p_UsrSpc);

        // Set pointer p_buffer to the offset of the first page. 
        //(dsBuffer is based on this pointer)
        p_buffer = p_UsrSpc + dsGH.OffFrstBuff;

        // Loop the number of buffers returned from general heading area
        // (dsGH is based on p_UsrSpc)
        for sf = 1 to dsGH.BuffRetrned;

           // Set pointer p_General to the offset of the general  
           // info. (dsGeneral is based on this pointer)
           p_General = p_UsrSpc + dsBuffer.OffGenInfo;

           // Do something with spool data. I don't know what yet
           // p_UsrSpc is the pointer of the user space. 
           // dsBuffer.OffPrintData is the Offset of the print data
           // ds.Buffer.SizePrintData is the size of the print data
           // Add Offset of print data to pointer of user space in hopes
           // of pointing to beginning of print data.
           pData = P_UsrSpc + dsBuffer.OffPrintData;

           // Get string of print data 
           WorkString = %Str(pData:dsBuffer.SizePrintData);

           // Increment pointer p_buffer by the length of the buffer
           p_buffer  = p_buffer + dsBuffer.LenBuffInfo;

        ENDFOR;


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.