Article 161219 of comp.os.vms:
In article <594n5u$fu7@decius.ultra.net>, rfeehan@ultranet.com (Robert Feehan) writes:
> 
> I would like idealy to be able to issue a command from DCL (or a C
> program if I have to) that would let me load the tape. I also need to
> be able to determine if a taope is loaded.
> 

Here's one way to determine if a tape is loaded.

$is_it_loaded:
$ mcr disk:[disk_directory]is_device_loaded.exe tapedrive: loaded
$ if loaded then goto loaded
$!
$! do something appropriate
$!
$ goto is_it_loaded
$loaded:
$! continue
$!


/* IS_DEVICE_LOADED.C
 *   is a program which assigns a channel to the device then issues a    *
 *   call to SYS$QIOW with IO$_PACKACK function.  The program takes two  *
 *   arguments:  a device name and a symbol name.  It sets the symbol to *
 *   "TRUE" if the device has media loaded, and to "FALSE" if the device *
 *   doesn't have media loaded.  If you supply it with insufficient      *
 *   arguments or give it an invalid device name, it exits with an error *
 *   status.  It needs PHY_IO priv to work.                              */

#include descrip
#include lib$routines
#include ssdef
#include starlet
#include string
#include iodef

unsigned long stat ;

#define ckstat(x) if (((stat = x) & 7) != 1) sys$exit(x)

main(int nargs, char **args)
{	unsigned short chan, iosb[4];
	$DESCRIPTOR(devnam, "");
	$DESCRIPTOR(symnam, "");
	$DESCRIPTOR(true, "TRUE");
	$DESCRIPTOR(false, "FALSE");

	if(nargs < 3)
		sys$exit(SS$_INSFARG);

	devnam.dsc$a_pointer = *++args;
	devnam.dsc$w_length = strlen(*args);
	symnam.dsc$a_pointer = *++args;
	symnam.dsc$w_length = strlen(*args);
	ckstat(sys$assign(&devnam, &chan, 0, 0));
	ckstat(sys$qiow(0, chan, IO$_PACKACK, iosb, 0, 0, 0, 0, 0, 0, 0, 0));
	if(iosb[0] == SS$_MEDOFL)
		return lib$set_symbol(&symnam, &false, 0);
	else
		return lib$set_symbol(&symnam, &true, 0);
}


