home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netdor2.zip / DISK_8 / IMAGE7.ZIP / PMCAMERA / PBIN2PSE.EXC next >
Text File  |  1992-12-17  |  4KB  |  157 lines

  1. /**************************************************************/
  2. /* PBIN2PSE  EXEC  Version 1.00                               */
  3. /* ----------------------------                               */
  4. /* Transforms a binary PSEG file (uploaded from a PS/2 to VM) */
  5. /* to the proper record length (LRECL)                        */
  6. /*                                                            */
  7. /* (C) Copyright IBM, 1992. All rights reserved.              */
  8. /* Written for IBM by John Hind                               */
  9. /*                                                            */
  10. /* 8/11/92   OS/2 EWS conforming version                      */
  11. /**************************************************************/
  12. Parse Upper Source . . . . . ME .;
  13. Address COMMAND;
  14. Parse Arg FN FT FM TFN TFT TFM '(' OPTIONS;
  15. Upper OPTIONS
  16.  
  17. FORCE=0
  18. Do I=1 to Words(OPTIONS)
  19.    WHICHOPT=Subword(OPTIONS,I,1)
  20.    Select
  21.       When Substr(WHICHOPT,1,1)="F" Then FORCE=1
  22.    Otherwise
  23.       Say 'Option "'WHICHOPT'" ignored.'
  24.    End
  25. End
  26.  
  27. Say ME "EXEC  Written by John Hind - Ver 8/11/92"
  28. Say
  29.  
  30. /* Set the kind of file to write */
  31. TRECFM='V';
  32. TRECL=16000; /*this is 1 larger than the max pseg 5A record size*/
  33. Signal On syntax;
  34. ABORT=0;
  35.  
  36. If FN='' | FN='?' & FT='' Then Signal TELL;
  37. If FT='' Then FT='PSEBIN';
  38. If FM='' then FM='*';
  39.  
  40. 'IOX STATE' FN FT FM '! FN FT FM RECS RECL RECFM';
  41. If RC^=0 Then Do;
  42.    Say ME 'cannot find the file' FN FT FM 'to convert';
  43.    exit 1;
  44. End;
  45.  
  46. If TFN='' | TFN='=' Then TFN=FN;
  47. If TFT='' Then TFT='PSEG38PP';
  48. If TFM='' Then TFM='A1';
  49. If TFM='=' Then TFM=FM;
  50.  
  51. 'STATE' TFN TFT TFM;
  52. If RC=0 Then Do;
  53.    If FORCE=0 Then Do
  54.       Say TFN TFT TFM "already exists.";
  55.       Say "Do you want to replace it? (Y or N)";
  56.       Pull ANS;
  57.       If Left(ANS,1)<>'Y' Then Exit 1;
  58.    End
  59.  
  60.    'ERASE' TFN TFT TFM;
  61. End;
  62.  
  63. /* now get 5A records and put them in output file */
  64. STR="";
  65. RECNUM=0;
  66.  
  67. Do Forever;
  68.    STRL=length(STR);
  69.    Do While STRL<TRECL & RECNUM<RECS;
  70.       'IOX READ' FN FT FM 'NOC 0 ! * TSTR';
  71.       If RC^=0 Then Do;
  72.          Say 'Record' RECNUM ': Error while trying to read' FN FT FM;
  73.          ABORT=99;
  74.          Signal FINIS;
  75.       End;
  76.  
  77.       RECNUM=RECNUM+1;
  78.       STR=STR||TSTR;
  79.       STRL=Length(STR);
  80.  
  81.       If RECNUM//100=0 Then Say RECNUM 'input record blocks processed';
  82.    End;
  83.  
  84.    If STRL=0 Then Signal FINIS;
  85.  
  86.    If Substr(STR,1,1)^='5A'x Then Do;
  87.       TEMP=''
  88.  
  89.       Do I=1 to 6
  90.          TEMP=TEMP D2x(C2d(Substr(STR,I,1)))
  91.       End
  92.  
  93.       TEMP=Strip(TEMP)
  94.       Say 'Record' RECNUM ': Data format invalid.  Data="'TEMP'"'
  95.       Say ''
  96.       Say 'NOTE: you may have uploaded the file using "F"ixed rather'
  97.       Say '      than "V"ariable mode which would have caused the last'
  98.       Say '      record to be improperly extended with non-pseg data.'
  99.       ABORT=96;
  100.       Signal FINIS;
  101.    End;
  102.  
  103.    LEN=C2d(Substr(STR,2,2));
  104.    If (LEN<8) | (LEN>(TRECL-1)) Then Do;
  105.       Say 'Record' RECNUM ': Output record length ('||LEN||') invalid';
  106.       TEMP=""
  107.       Do I=1 to 6
  108.          TEMP=TEMP D2x(C2d(Substr(STR,I,1)))
  109.       End
  110.       say '     first 6 bytes of record ->' TEMP
  111.       ABORT=97;
  112.       Signal FINIS;
  113.    End;
  114.  
  115.    OUTSTR=Substr(STR,1,LEN+1);
  116.    STR=Substr(STR,LEN+2);
  117.  
  118.    'IOX WRITE' TFN TFT TFM 'F='TRECFM 'L='TRECL 'NOC ( OUTSTR';
  119.    If RC^=0 Then Do;
  120.       Say 'Record' RECNUM ': Error while trying to write' TFN TFT TFM;
  121.       ABORT=98;
  122.       Signal FINIS;
  123.    End;
  124. End;
  125.  
  126. FINIS:
  127. 'FINIS' FN FT FM;
  128. 'FINIS' TFN TFT TFM;
  129. Say 'End' ME 'processing';
  130. Exit ABORT;
  131.  
  132. SYNTAX:
  133. Say "Bug:  Unfortunately this EXEC contains a REXX syntax error"
  134. Say 'Error' RC 'in line' SIGL':' Errortext(RC);
  135. Say Sourceline(SIGL);
  136. Signal FINIS;
  137.  
  138. TELL:
  139. Say 'This exec converts the PSEBIN binary upload file to a PSEG38PP '
  140. Say 'file.'
  141. Say 'This exec converts a binary PSEBIN file (uploaded from a PS/2 to VM)'
  142. Say 'to the proper record length (LRECL) required for page segments'
  143. Say ''
  144. Say ME 'fn <ft <fm <nfn <nft <nfm>>>>>  <( FORCE>'
  145. Say ''
  146. Say '  DEFAULTS:'
  147. Say '                        ft -> PSEBIN,    fm -> * '
  148. Say '            nfn -> fn, nft -> PSEG38PP, nfm -> A1'
  149. Say ''
  150. Say '  OPTIONS:'
  151. Say '           FORCE - overwrite output file if exists without'
  152. Say '                   prompting user for permission'
  153. Say ''
  154. Say '  (C) Copyright IBM, 1992. All rights reserved.'
  155. Say '  Written for IBM by John Hind'
  156. Exit
  157.