randbrd
Reads random block.
Defined in header <dos.h>
Syntax
#include <dos.h>
int randbrd(struct fcb *jd), int rent);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
randbrd reads rent number of records using the open file control block (FCB) pointed to by fcb. The records are read into memory at the current disk transfer address (DTA). They are read from the disk record indicated in the random record field of the FCB. This is accomplished by calling DOS system call 0x27.
The actual number of records read can be determined by examining the random record field of the FCB. The random record field is advanced by the number of records actually read.
Return value
The following values are returned, depending on the result of the randbrd operation:
0 All records are read. 1 End-of-file is reached and the last record read is complete. 2 Reading records would have wrapped around address 0xFFFF (as many records as possible are read). 3 End-of-file is reached with the last record incomplete.
See also
Example
#include <process.h>
#include <string.h>
Sinclude <stdio.h>
#include <dos.h>
int main(void)
{
char far *save_dta;
char line[80], buffer [256];
struct fcb blk;
int i, result;
/* get user input file name for dta */
printf("Enter drive and file name (no path i.e. a:file.dat)\n"
gets(line);
/* put file name in fcb */
if (!parsfnm(line, &blk, 1)) {
printf("Error in call to parsfnm\n");
exit(l);
printf("Drive #%d File: %s\n\n", blk.fcb_drive, blk.fcb_name);
/* open file with DOS fcb open file */
bdosptr(OxOF, &blk, 0);
/* save old dta and set new one */
save_dta = getdtaO;
setdta(buffer);
/* set up information for the new dta */
blk.fcb_recsize = 128;
blk;.fcb_random = 0L;
result = randbrd (&blk;, 1);
/* check results from randbrd */
if (Iresult)
printf ("Read OK\n\n");
else {
perror ("Error during read");
exit(l);
}
/* read in data from the new dta */
printf ("The first 128 characters are:\n"l
for (i=0; i<128; i++)
putchar (buffer[i]);
/* restore previous dta */
setdta(save_dta) ;
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dos.h/randbrd/
· short form /3.1/randbrd/