>lcCommand = "RUN copy /B *.pr1 " + lcPATH + lcOutputFileName
>&lcCommand
>
>*-- Start a new spool document for the open printer PROCEDURE DocOpen LPARAMETER tcDocName, <b>tcOutputFileName</b> LOCAL lIntState WITH THIS lIntState = .lInternal .lInternal = .T. IF ! lIntState .AddError(NULL) ENDIF IF ! .PrinterIsOpen() .AddError('DocOpen - no printer open to create Doc') .lInternal = lIntState RETURN .F. ENDIF IF .DocIsOpen() .AddError('DocOpen - Already open; forcing close') .DocClose() ENDIF IF TYPE('tcDocName') # 'C' tcDocName = SYS(2015) ENDIF LOCAL cDocInfo,nAllocPtr, <b>nAllocPtrFileName IF TYPE('tcOutputFileName') = 'C' nAllocPtrFileName = oHeap.AllocString(tcOutputFileName) ELSE nAllocPtrFileName = 0 ENDIF</b> nAllocPtr = .oHeap.AllocString(tcDocName) cDocInfo = NumToDWORD(nAllocPtr) + <b> ; NumToDWORD(nAllocPtrFileName) + ; REPL(CHR(0),4)</b> .nJobID = StartDocPrinter(.nhPrinter, 1, cDocInfo) IF .nJobID # 0 StartPagePrinter(.nhPrinter) .cDocName = tcDocName ELSE .AddError('StartDocPrinter API # ' + TRANSFORM(GetLastError())) .nJobID = NULL ENDIF .oHeap.DeAlloc(nAllocPtr) <b>IF nAllocPtrFileName # 0 .oHeap.DeAlloc(nAllocPtrFileName) ENDIF</b> .lInternal = lIntState RETURN .DocIsOpen() ENDWITH ENDPROCYou'd then use the class as follows to spool output from multiple files together into a single file:
SET CLASSLIB TO DirPrtClass.PRG ADDITIVE oPtr = CREATEOBJ('DirectPrintOutput') WITH oPtr .PrinterOpen('LPT1:') .DocOpen('MySpoolJob','C:\OutputDir\ConcatenatedFile') .DocWrite(FILETOSTR('MyPrintFile1.PRN')) .DocWrite(FILETOSTR('MyPrintFile2.PRN')) .DocWrite(FILETOSTR('MyPrintFile3.PRN')) .DocClose() ENDWITH oPtr = NULLThis would spool the three files together into a single output file, C:\OutputDir\ConcatenatedFile without stripping control sequences, interpretation by the GDI, or the need to shell out to DOS; in your case, where the concatenation is being directed to a printer ultimately, you could simply open the correct printer and skip the creation of the intermediate concatenation file if it's addressible from Windows.