From: Adrian Birkett [abirkett@unnecessary.csc.com] Sent: Tuesday, September 25, 2001 6:29 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: HOW DO I change FAB file attributes in C code? I whipped this up a few months ago as a records counter, but it will serve as an example. Ade /* RECS.C This program is an example of how to use RMS system service calls to OPEN, READ and CLOSE any file on a VMS system. The records are read sequentially and a summary report line of record count and minimum and maximum record sizes is displayed. */ #include #include #include #include int status; void main() { char filename[30], inrec[10000], bit[21]; int rec_count=0, exit=0, loopexit=0, maxsize=0, minsize=0; FILE *infile; struct FAB infile_fab; struct RAB infile_rab; do { printf("\n Enter File Name: "); scanf("%s",&filename); infile_fab = cc$rms_fab; infile_fab.fab$l_fna = &filename; infile_fab.fab$b_fns = strlen(filename); infile_fab.fab$b_fac = FAB$M_GET; infile_fab.fab$b_shr = FAB$M_GET | FAB$M_PUT | FAB$M_DEL | FAB$M_UPD; status = sys$open(&infile_fab); if ((status & SS$_NORMAL) != 1) { perror ("Open"); sys$exit(status); } infile_rab = cc$rms_rab; infile_rab.rab$l_fab = &infile_fab; infile_rab.rab$l_ubf = &inrec; infile_rab.rab$w_usz = sizeof(inrec); status = sys$connect(&infile_rab); if ((status & SS$_NORMAL) != 1) { perror ("Connect"); sys$exit(status); } rec_count = 0; status = sys$get(&infile_rab); if ((status & SS$_NORMAL) != 1) { perror ("1st Get"); sys$exit(status); } rec_count = 0; loopexit = 0; maxsize = infile_rab.rab$w_rsz; minsize = infile_rab.rab$w_rsz; while (loopexit == 0) { rec_count = rec_count + 1; if (infile_rab.rab$w_rsz < minsize) minsize = infile_rab.rab$w_rsz; if (infile_rab.rab$w_rsz > maxsize) maxsize = infile_rab.rab$w_rsz; status = sys$get(&infile_rab); if (!(status & SS$_NORMAL)) loopexit = 1; } status = sys$close(&infile_fab); if ((status && SS$_NORMAL) != 1) { perror ("Close"); sys$exit(status); } printf(" Record Count:%d, MaxSize:%d, MinSize:%d",rec_count,maxsize,minsize); } while (exit == 0); }