home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
wps
/
graphic
/
pmcamera
/
pbin2pse.exc
< prev
next >
Wrap
Text File
|
1992-12-16
|
4KB
|
157 lines
/**************************************************************/
/* PBIN2PSE EXEC Version 1.00 */
/* ---------------------------- */
/* Transforms a binary PSEG file (uploaded from a PS/2 to VM) */
/* to the proper record length (LRECL) */
/* */
/* (C) Copyright IBM, 1992. All rights reserved. */
/* Written for IBM by John Hind */
/* */
/* 8/11/92 OS/2 EWS conforming version */
/**************************************************************/
Parse Upper Source . . . . . ME .;
Address COMMAND;
Parse Arg FN FT FM TFN TFT TFM '(' OPTIONS;
Upper OPTIONS
FORCE=0
Do I=1 to Words(OPTIONS)
WHICHOPT=Subword(OPTIONS,I,1)
Select
When Substr(WHICHOPT,1,1)="F" Then FORCE=1
Otherwise
Say 'Option "'WHICHOPT'" ignored.'
End
End
Say ME "EXEC Written by John Hind - Ver 8/11/92"
Say
/* Set the kind of file to write */
TRECFM='V';
TRECL=16000; /*this is 1 larger than the max pseg 5A record size*/
Signal On syntax;
ABORT=0;
If FN='' | FN='?' & FT='' Then Signal TELL;
If FT='' Then FT='PSEBIN';
If FM='' then FM='*';
'IOX STATE' FN FT FM '! FN FT FM RECS RECL RECFM';
If RC^=0 Then Do;
Say ME 'cannot find the file' FN FT FM 'to convert';
exit 1;
End;
If TFN='' | TFN='=' Then TFN=FN;
If TFT='' Then TFT='PSEG38PP';
If TFM='' Then TFM='A1';
If TFM='=' Then TFM=FM;
'STATE' TFN TFT TFM;
If RC=0 Then Do;
If FORCE=0 Then Do
Say TFN TFT TFM "already exists.";
Say "Do you want to replace it? (Y or N)";
Pull ANS;
If Left(ANS,1)<>'Y' Then Exit 1;
End
'ERASE' TFN TFT TFM;
End;
/* now get 5A records and put them in output file */
STR="";
RECNUM=0;
Do Forever;
STRL=length(STR);
Do While STRL<TRECL & RECNUM<RECS;
'IOX READ' FN FT FM 'NOC 0 ! * TSTR';
If RC^=0 Then Do;
Say 'Record' RECNUM ': Error while trying to read' FN FT FM;
ABORT=99;
Signal FINIS;
End;
RECNUM=RECNUM+1;
STR=STR||TSTR;
STRL=Length(STR);
If RECNUM//100=0 Then Say RECNUM 'input record blocks processed';
End;
If STRL=0 Then Signal FINIS;
If Substr(STR,1,1)^='5A'x Then Do;
TEMP=''
Do I=1 to 6
TEMP=TEMP D2x(C2d(Substr(STR,I,1)))
End
TEMP=Strip(TEMP)
Say 'Record' RECNUM ': Data format invalid. Data="'TEMP'"'
Say ''
Say 'NOTE: you may have uploaded the file using "F"ixed rather'
Say ' than "V"ariable mode which would have caused the last'
Say ' record to be improperly extended with non-pseg data.'
ABORT=96;
Signal FINIS;
End;
LEN=C2d(Substr(STR,2,2));
If (LEN<8) | (LEN>(TRECL-1)) Then Do;
Say 'Record' RECNUM ': Output record length ('||LEN||') invalid';
TEMP=""
Do I=1 to 6
TEMP=TEMP D2x(C2d(Substr(STR,I,1)))
End
say ' first 6 bytes of record ->' TEMP
ABORT=97;
Signal FINIS;
End;
OUTSTR=Substr(STR,1,LEN+1);
STR=Substr(STR,LEN+2);
'IOX WRITE' TFN TFT TFM 'F='TRECFM 'L='TRECL 'NOC ( OUTSTR';
If RC^=0 Then Do;
Say 'Record' RECNUM ': Error while trying to write' TFN TFT TFM;
ABORT=98;
Signal FINIS;
End;
End;
FINIS:
'FINIS' FN FT FM;
'FINIS' TFN TFT TFM;
Say 'End' ME 'processing';
Exit ABORT;
SYNTAX:
Say "Bug: Unfortunately this EXEC contains a REXX syntax error"
Say 'Error' RC 'in line' SIGL':' Errortext(RC);
Say Sourceline(SIGL);
Signal FINIS;
TELL:
Say 'This exec converts the PSEBIN binary upload file to a PSEG38PP '
Say 'file.'
Say 'This exec converts a binary PSEBIN file (uploaded from a PS/2 to VM)'
Say 'to the proper record length (LRECL) required for page segments'
Say ''
Say ME 'fn <ft <fm <nfn <nft <nfm>>>>> <( FORCE>'
Say ''
Say ' DEFAULTS:'
Say ' ft -> PSEBIN, fm -> * '
Say ' nfn -> fn, nft -> PSEG38PP, nfm -> A1'
Say ''
Say ' OPTIONS:'
Say ' FORCE - overwrite output file if exists without'
Say ' prompting user for permission'
Say ''
Say ' (C) Copyright IBM, 1992. All rights reserved.'
Say ' Written for IBM by John Hind'
Exit