Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/util/makedf.sim
There is 1 other file named makedf.sim in the archive. Click here to see a list.
00010	OPTIONS(/C); COMMENT DIRECTFILE-SEQ FILE CONVERSION:
00020	
00030	MAKEDF - A PROGRAM TO CONVERT BETWEEN SIMULA DIRECTFILES-SEQ FILES.
00040	
00050	MAKEDF is a program which converts sequential files to SIMULA
00060	directfiles and SIMULA directfiles to sequential files.
00070	
00080	The sequential files can be line numbered according to DEC standard
00090	and may not contain any form feeds. The line number of the
00100	sequential file is used as location for the created directfile
00110	image. You are therefore adviced to use the line number increment 1
00120	(not 100 as is default in SOS) to avoid uneccesarily large
00130	directfiles. A file can be numbered with the increment 1 using pip:
00140	.COPY =FIL.EXT/O
00144	
00146	If the file is not line-numbered, MAKEDF will assume a numbering
00148	with the increment 1.
00150	
00160	When converting from directfiles to sequential files, lines
00170	beginning with "/*" in the directfile are not converted.
00180	
00190	.run foa:dirseq
00200	
00210	Input 'D' for directfile creation, 'S' for seqfile creation:
00220	D
00230	Give old seq file name: seq.in
00240	Give new direct file name: dirf.out
00250	This directfile already exists. Overwrite?
00260	yes
00270	Input directfile image size: 78
00280	? No legal line number:
00290	        a00003  THIS LINE HAS NO CORRECT LINE NUMBER
00300	? No legal line number:
00310	                SUCH LINES ARE NOT CONVERTED TO THE DIRECTFILE
00320	
00330	.start                  ! Conversion back to a sequential file
00340	
00350	Input 'D' for directfile creation, 'S' for seqfile creation:
00360	s
00370	Input old direct file name: dirf.out
00380	Input new sequential file name: seq.out
00390	Input directfile image size: 78
00400	
00410	[END OF DIRSEQ.HLP];
00420	
00430	BEGIN
00440	EXTERNAL INTEGER PROCEDURE rename;
00450	EXTERNAL REF (infile) PROCEDURE findinfile;
00470	EXTERNAL INTEGER PROCEDURE maxint, scanint;
00480	EXTERNAL PROCEDURE exit;
00490	EXTERNAL BOOLEAN PROCEDURE numbered;
00500	EXTERNAL TEXT PROCEDURE conc;
00510	REF (infile) inf; TEXT inf_name;
00520	REF (directfile) dirf; TEXT dirf_name;
00530	REF (outfile) outf; TEXT outf_name;
00540	BOOLEAN todirectfile;
00550	INTEGER linelength, location; TEXT linelt, buffer;
00560	CHARACTER c, tab; TEXT tabpos, twochars;
00565	BOOLEAN infnumbered;
00570	
00580	PROCEDURE get_linelength;
00583	BEGIN
00587	  again:
00591	  outtext("Input directfile image size: "); breakoutimage;
00600	  inimage; linelt:- copy(sysin.image.strip);
00610	  linelength:= scanint(linelt);
00612	  IF linelt.pos = 1 THEN
00614	  BEGIN outtext("?Illegal number"); outimage;
00615	    GOTO again;
00618	  END;
00620	END;
00630	
00640	PROCEDURE dfcreate;
00650	BEGIN
00660	  outtext("Give old seq file name: "); breakoutimage;
00670	  inimage; inf_name:- copy(sysin.image.strip);
00680	  outtext("Give new direct file name: "); breakoutimage;
00690	  inimage; dirf_name:- copy(sysin.image.strip);
00700	  inf:- findinfile(dirf_name);
00710	  IF inf =/= NONE THEN
00720	  BEGIN outtext("This directfile already exists. Overwrite?");
00730	    outimage; inimage; c:= inchar;
00740	    IF c NE 'Y' AND c NE 'y' THEN exit(0);
00750	    IF rename(inf,NOTEXT,FALSE) > -1 THEN
00760	    BEGIN outtext("? Could not delete old directfile."); outimage;
00770	      exit(0);
00780	    END;
00790	  END;
00800	  inf:- NEW infile(conc("INFIL ",inf_name));
00810	  get_linelength;
00820	  inf.open(blanks(linelength+6));
00830	  inf.inimage;
00840	  infnumbered:= numbered;
00860	  IF not infnumbered THEN inf.image:- inf.image.sub(1,linelength);
00880	  dirf:- NEW directfile(conc("DIRF ",dirf_name,
00890	  "/IMAGESIZE:",linelt));
00900	  dirf.open(NOTEXT);
00905	  IF not infnumbered THEN dirf.image:- inf.image ELSE
00910	  BEGIN dirf.image:- inf.image.sub(7,inf.image.length-6);
00920	    buffer:- inf.image.sub(1,5);
00925	  END;
00930	  WHILE NOT inf.endfile DO
00940	  BEGIN
00945	    IF infnumbered THEN
00948	    BEGIN
00950	      buffer.setpos(1);
00960	      location:= scanint(buffer);
00970	      IF buffer.pos = 1 THEN
00980	      BEGIN outtext("? No legal line number: "); outimage;
00990	        outtext(inf.image.strip); outimage; location:= location+1;
01000	      END;
01010	    END ELSE location:= location+1;
01020	    dirf.locate(location); dirf.outimage;
01040	    inf.inimage;
01050	  END;
01060	  inf.close; dirf.close;
01070	END;
01080	
01090	PROCEDURE sqcreate;
01100	BEGIN
01110	  outtext("Input old direct file name: "); breakoutimage;
01120	  inimage; dirf_name:- copy(sysin.image.strip);
01130	  outtext("Input new sequential file name: "); breakoutimage;
01140	  inimage; outf_name:- copy(sysin.image.strip);
01150	  inf:- findinfile(outf_name);
01160	  IF inf =/= NONE THEN
01170	  BEGIN outtext("This sequential file already exists. Overwrite?");
01180	    outimage; inimage; c:= inchar;
01190	    IF c NE 'Y' AND c NE 'y' THEN exit(0);
01200	    IF rename(inf,NOTEXT,FALSE) > -1 THEN
01210	    BEGIN outtext("? Could not delete old sequential file.");
01220	      outimage;
01230	      exit(0);
01240	    END;
01250	  END;
01260	  outf:- NEW outfile(conc("UTFIL ",outf_name,"/NUMBERED"));
01270	  get_linelength;
01280	  dirf:- NEW directfile(conc("DIRF ",dirf_name,
01290	  "/ACCESS:RONLY/IMAGESIZE:",linelt));
01300	  buffer:- blanks(linelength+11);
01310	  outf.open(buffer.sub(6,linelength+6));
01320	  dirf.open(buffer.sub(12,linelength));
01330	  tabpos:- outf.image.sub(6,1);
01340	  dirf.inimage;
01350	  buffer:- buffer.sub(5,6); location:= 100000;
01360	  twochars:- dirf.image.sub(1,2);
01370	  WHILE NOT dirf.endfile DO
01380	  BEGIN
01390	    location:= location+1;
01400	    IF twochars NE "/*" THEN
01410	    BEGIN
01420	      buffer.putint(location);
01430	      tabpos.setpos(1); tabpos.putchar(tab);
01440	      outf.outimage;
01450	    END;
01460	    dirf.inimage;
01470	  END;
01480	  outf.close; dirf.close;
01490	END;
01500	
01510	COMMENT main program;
01520	tab:= char(9);
01530	WHILE dirf == NONE DO
01540	BEGIN
01550	  outtext("Input 'D' for directfile creation,"
01560	  " 'S' for seqfile creation:");
01570	  outimage; inimage;
01580	  c:= inchar;
01590	  IF c = 'D' OR c = 'd' THEN dfcreate ELSE
01600	  IF c = 'S' OR c = 's' THEN sqcreate;
01610	END;
01620	END;