stergios@rocky.STANFORD.EDU (Stergios Marinopoul) (11/26/87)
Finally got the "C" based use of QIO to work. Here's the program
... I know I don't indent the way you 'purist' like for me to but here
it is anyway with one or two comments for you! Thats why someone wrote cb,
right?
main()
{
int ind;
int i,j,k,l,m,n,nrec;
unsigned char a[32767];
nrec = 0;
for(i = 0 ; ; )
{
ind = rtap(a); /* Here's the tape reading routine ... */
/* read the tape into buffer 'a' */
if(ind < 1)
{
printf("Number Of Records = %d\n",nrec);
exit();
}
nrec++;
}
}
/* Here's the Source for the rtap routine */
#include iodef
#include ssdef
#include descrip
#include stdlib
/* Here's The Structure For The IOSTATUS Block */
struct
{
short cond_val;
short xfer_count;
int info;
} status_block;
int rtap(buff)
unsigned char buff[];
{
register status;
$DESCRIPTOR(tape,"MFA0:");
/* This the CRITICAL One! It 'properly' */
/* Initializes 'MFA0:' the way QIO wants it */
static int opndone = { 0 };
static short chan;
unsigned int i,k,l,m,n,ind,dummy;
dummy = 0;
if(opndone == 0)
{
opndone = 1;
/* OK, Let's do the ASSIGN */
if(((status = sys$assign(&tape,&chan,0,0)) & 1) != 1)
LIB$STOP(status);
}
/* Now, For the READ */
status = sys$qiow(1,chan,IO$_READLBLK,&status_block,
0,&status_block,buff,32767,0,0,0,0);
if(status == SS$_ENDOFFILE || status == SS$_ENDOFTAPE)return(0);
if((status & 1) != 1)
{
printf("Error Occurred: System Status Return Value = %d\n",status);
return(-1);
}
return(status_block.xfer_count);
}
That's about it! The $DESCRIPTOR was the big 'catch'.
--
% Stergios Marinopoulos % GO: Wall Street
% UUCP: !sun!rocky!stergios % DECNET: star::stergios
% ARPA: f.flex@macbeth.stanford.edu % BELL: (415) 321-7678
% USnail: S. Marinopoulos Crothers Memorial #690, Stanford, CA. 94305