COPYWRITE/EXAMPLES/TRANSFORM
 $ Set Sharing = PRIVATE                                                00100000Transform 
 $ Set Installation 1                                                   00101000Transform 
 $ Set Tracing                                                          00102000Transform 
Begin                                                                   00103000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00104000Transform 
%                  COPYWRITE Transform Source                        %  00105000Transform 
%                                                                    %  00106000Transform 
% This Library exports transform functions which may be used         %  00107000Transform 
% by the METALOGIC COPYWRITE library when transforming data          %  00108000Transform 
% during the transfer of files into a CDROM volume image.            %  00109000Transform 
%                                                                    %  00110000Transform 
%                         History                                    %  00111000Transform 
%                                                                    %  00112000Transform 
% 03/07/98  Initial version                                          %  00113000Transform 
%                                                                    %  00114000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00115000Transform 
                                                                        00116000Transform 
Define                                                                  00117000Transform 
  CAND(A,B) = (If (A) then (B) Else FALSE)#;                            00118000Transform 
                                                                        00119000Transform 
 $ Set Omit = Not Tracing                                               00120000Transform 
                                                                        00121000Transform 
File                                                                    00122000Transform 
  ReportFile(Kind = PRINTER,FrameSize = 8,BlockStructure=EXTERNAL,      00123000Transform 
             MaxRecSize = 132,FileUse = OUT );                          00124000Transform 
PROCEDURE Report(Text);                                                 00125000Transform 
 Value Text;                                                            00126000Transform 
 String Text;                                                           00127000Transform 
   Write(ReportFile,LENGTH(Text),Text);                                 00128000Transform 
                                                                        00129000Transform 
PROCEDURE DumpArray(Who,A,iStart,nWords,Writer);                        00130000Transform 
 Value Who,iStart,nWords;                                               00131000Transform 
 String Who;                                                            00132000Transform 
 Array A[0];                                                            00133000Transform 
 Integer iStart,nWords;                                                 00134000Transform 
 PROCEDURE Writer(Text);                                                00135000Transform 
  Value Text;                                                           00136000Transform 
  String Text;                                                          00137000Transform 
   FORMAL;                                                              00138000Transform 
 Begin                                                                  00139000Transform 
   Define                                                               00140000Transform 
     WordsPerLine = 5#,                                                 00141000Transform 
     CAND(A,B) = (If (A) then (B) Else FALSE)#;                         00142000Transform 
   String                                                               00143000Transform 
     Line;                                                              00144000Transform 
   Integer                                                              00145000Transform 
     K,                                                                 00146000Transform 
     iWord,                                                             00147000Transform 
     nSame,                                                             00148000Transform 
     cLine,                                                             00149000Transform 
     iLast;                                                             00150000Transform 
   Writer(Who !! " [" !! String(iStart,*) !! "] for " !!                00151000Transform 
          String(nWords,*) !! " Words");                                00152000Transform 
   Line:="(" !! String(iStart,8) !! ") ";                               00153000Transform 
   iLast:=((iWord:=iStart)+nWords-1);                                   00154000Transform 
   While (iWord <= iLast) Do                                            00155000Transform 
   Begin                                                                00156000Transform 
     nSame:=iWord+1;                                                    00157000Transform 
     While CAND(nSame <= iLast,A[nSame] IS A[iWord]) Do nSame:=*+1;     00158000Transform 
     nSame:=*-iWord;                                                    00159000Transform 
     If (WordsPerLine-cLine) < (K:=If (nSame > 1) then 2 else 1) then   00160000Transform 
     Begin                                                              00161000Transform 
       Writer(Line);                                                    00162000Transform 
       Line:="(" !! String(iWord,8) !! ") ";                            00163000Transform 
       cLine:=0;                                                        00164000Transform 
     End;                                                               00165000Transform 
     Line:=* !! Translate(String4(Pointer(A[iWord],4),12),              00166000Transform 
                          HexToEBCDIC) !! " ";                          00167000Transform 
     cLine:=*+1;                                                        00168000Transform 
     If (nSame > 1) then                                                00169000Transform 
     Begin                                                              00170000Transform 
       Line:=* !! "for " !! String(nSame,8) !! " ";                     00171000Transform 
       cLine:=*+1;                                                      00172000Transform 
     End;                                                               00173000Transform 
     iWord:=*+nSame;                                                    00174000Transform 
   End;                                                                 00175000Transform 
   If (nWords > 0) then                                                 00176000Transform 
     Writer(Line);                                                      00177000Transform 
 End of DumpArray;                                                      00178000Transform 
                                                                        00179000Transform 
 $ Pop Omit                                                             00180000Transform 
                                                                        00181000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00182000Transform 
%                       TRANSFORM Interface                          %  00183000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00184000Transform 
                                                                        00185000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00186000          
%$ Include "COPYWRITE/LIBRARY." 10820000 - 11375000                     00187000          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00188000          
%        Note:  Included here for Trial Customers                       00189000          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00190000CopyWrite 
%              Start of Transform Interface Include Range            %  00191000CopyWrite 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00192000CopyWrite 
                                                                        00193000CopyWrite 
Define                                                                  00194000CopyWrite 
  %  Result                                                             00195000CopyWrite 
  CWTr_ErrorV                       = 0#,                               00196000CopyWrite 
  CWTr_OKV                          = 1#,                               00197000CopyWrite 
  CWTr_SkipRecordV                  = 3#,                               00198000CopyWrite 
  CWTr_SkipFileV                    = 5#,                               00199000CopyWrite 
  CWTr_SelectFileAndChangeTitleV    = 7#,                               00200000CopyWrite 
  CWTr_CreateNewFileV               = 9#,                               00201000CopyAndCat
  %  Context                                                            00202000CopyWrite 
  CWTr_OpenVolumeV                  = 1#,                               00203000CopyWrite 
  CWTr_StartOfFileV                 = 2#,                               00204000CopyWrite 
  CWTr_DataRecordV                  = 3#,                               00205000CopyWrite 
  CWTr_EndOfFileV                   = 4#,                               00206000CopyWrite 
  CWTr_CloseVolumeV                 = 5#,                               00207000CopyWrite 
  CWTr_OpenFileSystemV              = 6#,                               00208000CopyAndCat
  CWTr_CloseFileSystemV             = 7#,                               00209000CopyAndCat
  %  File Information                                                   00210000CopyWrite 
  CWTr_FileStructure(A)             = A[0]#,                            00211000CopyWrite 
  CWTr_FileType(A)                  = A[1]#,                            00212000CopyWrite 
  CWTr_SectorSize(A)                = A[2]#,                            00213000CopyWrite 
  CWTr_ExtMode(A)                   = A[3]#,                            00214000CopyWrite 
  CWTr_Units(A)                     = A[4]#,                            00215000CopyWrite 
  CWTr_EOFSector(A)                 = A[5]#,                            00216000CopyWrite 
  CWTr_EOFLastBits(A)               = A[6]#,                            00217000CopyWrite 
  CWTr_NumberOfSectors(A)           =                                   00218000UnAllocate
               (CWTr_EOFSector(A)+REAL(CWTr_EOFLastBits(A)^=0))#,       00219000UnAllocate
  CWTr_RowTail(A)                   = A[7]#,                            00220000CopyWrite 
  CWTr_RowSize(A)                   = A[8]#,                            00221000CopyWrite 
  CWTr_BlockSize(A)                 = A[9]#,                            00222000CopyWrite 
  CWTr_MaxRecSize(A)                = A[10]#,                           00223000CopyWrite 
  CWTr_LastRecord(A)                = A[11]#,                           00224000CopyWrite 
  CWTr_Filelength(A)                = A[12]#,                           00225000CopyWrite 
  CWTr_HdrLength(A)                 = A[13]#,                           00226000CopyWrite 
  CWTr_FileKind(A)                  = A[14]#,                           00227000CopyWrite 
  CWTr_FileSystem(A)                = A[15]#,                           00228000CopyWrite 
    CWTr_LibraryMaintenanceV        = 0#,                               00229000CopyWrite 
    CWTr_ISO9660V                   = 1#,                               00230000CopyWrite 
    CWTr_JOLIETV                    = 2#,                               00231000CopyWrite 
  CWTr_RecordSizeInBytes(A)         = A[16]#,                           00232000CopyWrite 
  CWTr_ApplyExtendedAttributes(A)   = Boolean(A[17])#,                  00233000CopyWrite 
  CWTr_RequestedFileKind(A)         = A[18]#,                           00234000CopyWrite 
  CWTr_VolumeIdentifierIndex(A)     = A[19]#,                           00235000CopyWrite 
  CWTr_VolumeIdentifierSize(A)      = A[20]#,                           00236000CopyWrite 
  CWTr_VolumeIdentifier(A)          =                                   00237000CopyWrite 
               String(Pointer(A[CWTr_VolumeIdentifierIndex(A)],8),      00238000CopyWrite 
                      CWTr_VolumeIdentifierSize(A))#,                   00239000CopyWrite 
  CWTr_VolumeTitleIndex(A)          = A[21]#,                           00240000CopyWrite 
  CWTr_VolumeTitleSize(A)           = A[22]#,                           00241000CopyWrite 
  CWTr_VolumeTitle(A)               =                                   00242000CopyWrite 
               String(Pointer(A[CWTr_VolumeTitleIndex(A)],8),           00243000CopyWrite 
                      CWTr_VolumeTitleSize(A))#,                        00244000CopyWrite 
  CWTr_ToHostNameIndex(A)           = A[23]#,                           00245000CopyWrite 
  CWTr_ToHostNameSize(A)            = A[24]#,                           00246000CopyWrite 
  CWTr_ToHostName(A)                =                                   00247000CopyWrite 
               String(Pointer(A[CWTr_ToHostNameIndex(A)],8),            00248000CopyWrite 
                      CWTr_ToHostNameSize(A))#,                         00249000CopyWrite 
  CWTr_TransformStringIndex(A)      = A[25]#,                           00250000CopyWrite 
  CWTr_TransformStringSize(A)       = A[26]#,                           00251000CopyWrite 
  CWTr_TransformString(A)           =                                   00252000CopyWrite 
               String(Pointer(A[CWTr_TransformStringIndex(A)],8),       00253000CopyWrite 
                      CWTr_TransformStringSize(A))#,                    00254000CopyWrite 
  CWTr_PublisherIndex(A)            = A[27]#,                           00255000CopyWrite 
  CWTr_PublisherSize(A)             = A[28]#,                           00256000CopyWrite 
  CWTr_Publisher(A)                 =                                   00257000CopyWrite 
               String(Pointer(A[CWTr_PublisherIndex(A)],8),             00258000CopyWrite 
                      CWTr_PublisherSize(A))#,                          00259000CopyWrite 
  CWTr_DataPreparerIndex(A)         = A[29]#,                           00260000CopyWrite 
  CWTr_DataPreparerSize(A)          = A[30]#,                           00261000CopyWrite 
  CWTr_DataPreparer(A)              =                                   00262000CopyWrite 
               String(Pointer(A[CWTr_DataPreparerIndex(A)],8),          00263000CopyWrite 
                      CWTr_DataPreparerSize(A))#,                       00264000CopyWrite 
  CWTr_NumberOfRows(A)              = A[31]#,                           00265000UnAllocate
  CWTr_NumberOfAllocatedRows(A)     = A[32]#,                           00266000UnAllocate
  CWTr_NumberOfUnAllocatedRowsBeforeLastRow(A)                          00267000UnAllocate
                                    = A[33]#,                           00268000UnAllocate
  CWTr_LastRow(A)                   = A[34]#,                           00269000UnAllocate
  CWTr_LastRowSize(A)               = A[35]#,                           00270000UnAllocate
  CWTr_LastAllocatedRow(A)          = A[36]#,                           00271000UnAllocate
                                                                        00272000UnAllocate
  CWTr_FileInfoSizeInWords(A)       = A[CWTr_FixedSizeInWordsV-1]#,     00273000CopyWrite 
  CWTr_FixedSizeInWordsV            = 50#,                              00274000CopyWrite 
                                                                        00275000CopyWrite 
  CWTr_EndOfDefinitions=#;                                              00276000CopyWrite 
                                                                        00277000CopyWrite 
Define                                                                  00278000CopyWrite 
  Declare_Copywrite_Transform_Function(CWTr_Name) =                     00279000CopyWrite 
     Integer PROCEDURE CWTr_Name(Context,Hdr,FileInfo,                  00280000CopyWrite 
                                 Record,sRecord,InsertRecord,           00281000CopyWrite 
                                 Scratch,Report,Options,Reason);        00282000CopyWrite 
      Value Context,Options;                                            00283000CopyWrite 
      Integer Context,sRecord;                                          00284000CopyWrite 
      Array Hdr,FileInfo,Record,Scratch[0];                             00285000CopyWrite 
      Real Options;                                                     00286000CopyWrite 
      String Reason;                                                    00287000CopyWrite 
      Boolean PROCEDURE InsertRecord(pDataRecord,sDataRecord,Reason);   00288000CopyWrite 
       Value pDataRecord,sDataRecord;                                   00289000CopyWrite 
       Pointer pDataRecord;                                             00290000CopyWrite 
       Integer sDataRecord;                                             00291000CopyWrite 
       String Reason;                                                   00292000CopyWrite 
        FORMAL;                                                         00293000CopyWrite 
      PROCEDURE Report(Text);                                           00294000CopyWrite 
       Value Text;                                                      00295000CopyWrite 
       String Text;                                                     00296000CopyWrite 
        FORMAL#;                                                        00297000CopyWrite 
                                                                        00298000CopyWrite 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00299000CopyWrite 
%                End of Transform Interface Include Range            %  00300000CopyWrite 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00301000CopyWrite 
                                                                        00302000          
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00303000Transform 
 %                     ASCIICrLf                                     %  00304000Transform 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00305000Transform 
                                                                        00306000Transform 
Declare_Copywrite_Transform_Function(CWTr_ASCIICrLf);                   00307000Transform 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00308000Transform 
 % Description:                                                      %  00309000Transform 
 %   This is a transform for transforming files into the format      %  00310000Transform 
 %   commonly used on Windows systems. The format created is         %  00311000Transform 
 %   variable length text records in ASCII, with each line           %  00312000Transform 
 %   terminated by a CR LF.                                          %  00313000Transform 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  00314000Transform 
 Begin                                                                  00315000Transform 
   Label                                                                00316000Transform 
     OutOfCWTr_ASCIICrLf;                                               00317000Transform 
   Define                                                               00318000Transform 
     Return(R) =                                                        00319000Transform 
       Begin                                                            00320000Transform 
         CWTr_ASCIICrLf:=(R);                                           00321000Transform 
         Go OutOfCWTr_ASCIICrLf;                                        00322000Transform 
       End#;                                                            00323000Transform 
   Pointer                                                              00324000Transform 
     pRecord;                                                           00325000Transform 
                                                                        00326000Transform 
 $ Set Omit = Not Tracing                                               00327000Transform 
     DumpArray("CWTr_ASCIICrLf " !! String(sRecord,*) !! " bytes",      00328000Transform 
               Record,0,sRecord DIV 6 + 1,                              00329000Transform 
               Report);                                                 00330000Transform 
 $ Pop Omit                                                             00331000Transform 
                                                                        00332000Transform 
   Case Context Of                                                      00333000Transform 
   Begin                                                                00334000Transform 
 CWTr_OpenVolumeV:                                                      00335000Transform 
 CWTr_StartOfFileV:                                                     00336000Transform 
     Return(CWTr_OKV);                                                  00337000Transform 
 CWTr_DataRecordV:                                                      00338000Transform 
     Case CWTR_FileStructure(FileInfo) Of                               00339000Transform 
     Begin                                                              00340000Transform 
   Value(ALIGNED180):                                                   00341000Transform 
       pRecord:=Pointer(Record[0],8);                                   00342000Transform 
       Case CWTr_ExtMode(FileInfo) Of                                   00343000Transform 
       Begin                                                            00344000Transform 
     Value(OCTETSTRING):                                                00345000Transform 
         ;                                                              00346000Transform 
     Value(ASCII):                                                      00347000Transform 
         While CAND(sRecord > 0,                                        00348000Transform 
                    pRecord+(sRecord-1) = 47"20" For 1) Do              00349000Transform 
           sRecord:=*-1;                                                00350000Transform 
         Replace pRecord+sRecord By 47"0D0A" for 2;                     00351000Transform 
         sRecord:=*+2;                                                  00352000Transform 
     Else:                                                              00353000Transform 
         While CAND(sRecord > 0,                                        00354000Transform 
                    pRecord+(sRecord-1) = 48"40" For 1) Do              00355000Transform 
           sRecord:=*-1;                                                00356000Transform 
         Replace pRecord+sRecord By 48"0D25" for 2;                     00357000Transform 
         sRecord:=*+2;                                                  00358000Transform 
         Replace pRecord By pRecord For sRecord With EBCDICToASCII;     00359000Transform 
       End Case;                                                        00360000Transform 
   Value(STREAM):                                                       00361000Transform 
       pRecord:=Pointer(Record[0],8);                                   00362000Transform 
       Case CWTr_ExtMode(FileInfo) Of                                   00363000Transform 
       Begin                                                            00364000Transform 
     Value(EBCDIC):                                                     00365000Transform 
         Replace pRecord By pRecord For sRecord With EBCDICToASCII;     00366000Transform 
     Else:                                                              00367000Transform 
         ;                                                              00368000Transform 
       End Case;                                                        00369000Transform 
   Else:                                                                00370000Transform 
       ;                                                                00371000Transform 
     End Case;                                                          00372000Transform 
     Return(CWTr_OKV);                                                  00373000Transform 
 CWTr_EndOfFileV:                                                       00374000Transform 
 CWTr_CloseVolumeV:                                                     00375000Transform 
     Return(CWTr_OKV);                                                  00376000Transform 
 Else:                                                                  00377000Transform 
     Return(CWTr_ErrorV);                                               00378000Transform 
   End Case;                                                            00379000Transform 
                                                                        00380000Transform 
OutOfCWTr_ASCIICrLf:                                                    00381000Transform 
 End of CWTr_ASCIICrLf;                                                 00382000Transform 
                                                                        00383000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   00384000Transform 
%                        Initialization                             %   00385000Transform 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   00386000Transform 
                                                                        00387000Transform 
Export                                                                  00388000Transform 
  CWTr_ASCIICrLf as "ASCIICRLF";                                        00389000Transform 
                                                                        00390000Transform 
Freeze(TEMPORARY);                                                      00391000Transform 
End.                                                                    00392000Transform