Article 166113 of comp.os.vms:
Zafrir Benyehuda <zbenye@SPRYNET.COM> asks:
> How does one convert VFC files (created by COBOL ReportWriter) into
> plain CR/LF-spaced files. The intent is to be able to distribute
> reports, currently only printed, through email, or to be able to
> download them into PC-based applications.

The VMS C libraries know how to correctly interpret 
the various RMS formats, including VFC print controls.

The (rather general) C program below is likely to solve your problem.
Compile it via CC/STANDARD=VAXC .

Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdvms.dnet.gwdg.de
GWDG, D-37077 Goettingen, F.R.Germany   |       Disclaimer: No claim intended!
<moeller@decus.decus.de>  ----- <moeller@gwdg.de>  -----  <w.moeller@ieee.org>
--------------------------------------------------------------------------------
/* convert to "CR" format with a little help from VAXCRTL */
/* w.j.m. may 1993 */

/**** NOTE: input file must not contain <NUL>s ("POSIX text files" only) ****/

#include <stdio.h>
#include <perror.h>

#define MAXLINE 32767	/* sort of maximum "record size" */

static error(char *,int/*logical*/);	/* forward */

main(argc,argv)
int argc;
char **argv;
{
	char line[MAXLINE+1];	/* room for fgets() & <NUL> */
	char oline[MAXLINE+2];	/* same, plus room for a '\n' */
	char *cp,*ocp;
	FILE *f1,*f2;
	int nlines;
	enum {
		st_default,	/* not at left margin */
		st_cr,		/* <CR> seen */
		st_lf,		/* at left margin, not top of page */
		st_ff		/* at top of page */
	} state;


	if(argc != 3) error("%-E-Need 2 parameters: inputfile outputfile\n",0);


	if((f1 = fopen(argv[1],"r")) == NULL)
		error("%-E-Error opening input",1);

	strcpy(line,"dna="); strcat(line,argv[1]);
	if((f2 = fopen(argv[2],"w","rfm=var","rat=cr",line)) == NULL)
		error("%-E-Error opening output",1);


#define OUTPUT_oline \
do {\
	*ocp++ = '\n'; *ocp++ = '\0';\
	if(fputs(oline,f2) == EOF) error("%-E-Write error",1);\
	nlines++;\
	ocp = oline;\
} while(0)

	line[MAXLINE] = '\0';	/* delimiter, untouched by fgets() */

	nlines = 0;

	state = st_lf;		/* do honor leading <FF> */
	ocp = oline;
	while(fgets(line,MAXLINE,f1) != NULL) {
	    for(cp = line; *cp; cp++) {
		switch(*cp) {
		  case '\r':			/* <CR> */
			switch(state) {
			  case st_ff:
			  case st_lf:
			  case st_cr:
				break;		/* redundant, ignore */
			  default:
				state = st_cr;
				break;
			}
			break;

		  case '\f':			/* <FF> */
			switch(state) {
			  case st_ff:
				break;		/* "redundant", ignore */
			  case st_cr:
			  default:
				OUTPUT_oline;
				/* drop thru */
			  case st_lf:
				state = st_ff;
				goto copyit;
			}
			break;

		  case '\n':			/* <LF> */
			OUTPUT_oline;
			state = st_lf;
			break;

		  default:
			if(state == st_cr) *ocp++ = '\r';
			state = st_default;
copyit:
			*ocp++ = *cp;
			break;
		}		/* switch(*cp) */
	    }			/* for(cp...) */

	    if(state != st_lf) {	/* i.e. line not terminated by '\n' */
		OUTPUT_oline;		/* => fake '\n' (avoid overflow) */
		state = st_lf;
	    }

	}			/* while(fgets()...) */

	if(ferror(f1)) error("%-E-Read error",1);


	fprintf(stderr,"%%-S-Copied %d lines to %s\n",nlines,
 		fgetname(f2,line));
}


static error(char *str,int/*logical*/ k)
{
	if(k) perror(str);
	else fputs(str,stderr);

	sys$exit(0x10000002);	/* %-E-noname, noprint */
}
--------------------------------------------------------------------------------
Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdvms.dnet.gwdg.de
GWDG, D-37077 Goettingen, F.R.Germany   |       Disclaimer: No claim intended!
<moeller@decus.decus.de>  ----- <moeller@gwdg.de>  -----  <w.moeller@ieee.org>


