F$DEVICE()

From VSI OpenVMS Wiki
Jump to: navigation, search

F$DEVICE is a lexical function that returns the device names of all devices on a system that meet the specified selection criteria. Note that the device names are returned in random order.

Syntax

F$DEVICE([search_devnam],[devclass],[devtype], [stream-id])

Return Value

A character string containing the name of a device in the system's list of devices. After the last device name in the system's device list is returned, the F$DEVICE function returns a null string ("").

Arguments

search_devnam

Specifies the name of the device for which F$DEVICE is to search. The asterisk (*) and the percent sign (%) wildcard characters are allowed in the search_devnam argument. Specify the search_devnam argument as a character string expression.

devclass

Specifies the device class for which F$DEVICE is to search. Specify the devclass argument as a character string expression that corresponds to a valid device class name:

  • DISK Disk device
  • TAPE Tape device
  • SCOM Synchronous communications device
  • CARD Card reader
  • TERM Terminal
  • LP Line printer
  • REALTIME Real-time
  • MAILBOX Mailbox
  • MISC Miscellaneous device

devtype

Specifies the device type for which F$DEVICE is to search. Specify the devtype argument as a character string expression that corresponds to a valid type name. See the DVI$_DEVTYPE item in the $GETDVI system service for additional information. NOTE Specifying a device type without specifying a device class will result in an error.

stream-id

A positive integer representing the search stream identification number. The search stream identification number is used to maintain separate search contexts when you use the F$DEVICE function more than once and when you supply different search criteria. If you use the F$DEVICE function more than once in a command procedure and if you also use different search criteria, specify stream-id arguments to identify each search separately. If the search criteria are changed in a call before the device name list is exhausted, the context will be reinitialized and the search will restart. If you omit the stream-id argument, the F$DEVICE function assumes an implicit single search stream. That is, the F$DEVICE function starts searching at the beginning each time you specify different search criteria.


Examples

$ START: 
$     DEVICE_NAME = F$DEVICE("*0:","DISK","RA60") 
$     IF DEVICE_NAME .EQS. "" THEN EXIT 
$     SHOW SYMBOL DEVICE_NAME 
$     GOTO START 

This command procedure displays the device names of all the RA60s on a unit numbered 0. Because no stream-id argument is specified, F$DEVICE uses an implicit search stream. Each subsequent use of the F$DEVICE function uses the same search criteria to return the next device name. After the last device name is displayed, the F$DEVICE function returns a null string and the procedure exits.