VISA Find Resource

Queries the system to locate the devices associated with a specified interface.

Note  For the VISA Find Resource function, the DMA2800 is not supported by VISA on the Macintosh.

expression matches the value specified with the devices available for a particular interface. The description string specified sets the criteria to search an interface, GPIB, GPIB-VXI, VXI, All VXI, Serial or All, for existing devices. The following table includes valid special characters and operators.

Special Characters and Operators Meaning
?Matches any one character.
\Makes the character that follows it an ordinary character instead of special character. For example, when a question mark follows a backslash (\?), it matches the ? character instead of any one character.
[list]Matches any one character from the enclosed list. You can use a hyphen to match a range of characters.
[^list]Matches any character not in the enclosed list. You can use a hyphen to match a range of characters.
*Matches 0 or more occurrences of the preceding character or expression.
+Matches 1 or more occurrences of the preceding character or expression.
Exp|expMatches either the preceding or following expression. The or operator | matches the entire expression that precedes or follows it and not just the character that precedes or follows it. For example, VXI|GPIB means (VXI)|(GPIB), not VX(I|G)PIB.
(exp)Grouping characters or expressions.
The search criteria specified in the expression parameter has two parts, a regular expression over a resource string and an optional logical expression over attribute values. The regular expression is matched against the resource strings of resources known to the VISA Resource Manager. If the resource string matches the regular expression, the attribute values of the resource are matched against the expression over attribute values. If the match is successful, the resource has met the search criteria and is added to the list of resources found. All resource strings returned by VISA Find Resource are always recognized by VISA Open. However, VISA Find Resource does not necessarily return all strings that you can pass to viParseRsrc() or VISA Open. This is especially true for network and TCPIP resources. The following table includes valid regular expressions.

Regular Expression Sample Matches
GPIB?*INSTRMatches GPIB0::2::INSTR, GPIB1::1::1::INSTR, and

GPIB-VXI1::8::INSTR.

GPIB[0-9]*::?*INSTRMatches GPIB0::2::INSTR and GPIB1::1::1::INSTR but not

GPIB-VXI1::8::INSTR.

GPIB[^0]::?*INSTRMatches GPIB1::1::1::INSTR but not GPIB0::2::INSTR or GPIB12::8::INSTR.
VXI?*INSTRMatches VXI0::1::INSTR but not GPIB-VXI0::1::INSTR.
GPIB-VXI?*INSTRMatches GPIB-VXI0::1::INSTR but not VXI0::1::INSTR.
?*VXI[0-9]*::?*INSTRMatches VXI0::1::INSTR and GPIB-VXI0::1::INSTR.
ASRL[0-9]*::?*INSTRMatches ASRL1::INSTR but not VXI0::5::INSTR.
ASRL1+::INSTRMatches ASRL1::INSTR and ASRL11::INSTR but not ASRL2::INSTR.
(GPIB|VXI)?*INSTRMatches GPIB1::5::INSTR and VXI0::3::INSTR but not ASRL2::INSTR.
(GPIB0|VXI0)::1::INSTRMatches GPIB0::1::INSTR and VXI0::1::INSTR.
?*INSTRMatches all INSTR (device) resources.
?*VXI[0-9]*::?*MEMACCMatches VXI0::MEMACC and GPIB-VXI1::MEMACC.
VXI0::?*Matches VXI0::1::INSTR, VXI0::2::INSTR, and VXI0::MEMACC.
?*Matches all resources.
By using the optional attribute expression, you can construct flexible and powerful expressions with the use of logical ANDs (&&), ORs(||), and NOTs (!). You can use equal (==) and unequal (!=) comparators to compare attributes of any type, and other inequality comparators (>, <, >=, <=) to compare attributes of numeric type. Use only global attributes in the attribute expression. Local attributes are not allowed in the logical expression part of the expr parameter. The following table includes valid expression parameters.

Expr Parameter Meaning
GPIB[0-9]*::?*::?*::INSTR

{VI_ATTR_GPIB_SECONDARY_ADDR > 0 && VI_ATTR_GPIB_SECONDARY_ADDR < 10}

Find all GPIB devices that have secondary addresses from 1 to 9.
ASRL?*INSTR{VI_ATTR_ASRL_BAUD == 9600}Find all serial ports configured at 9600 baud.
?*VXI?INSTR{VI_ATTR_MANF_ID == 0xFF6 && !(VI_ATTR_VXI_LA ==0 || VI_ATTR_SLOT <= 0)}Find all VXI instrument resources having manufacturer ID FF6 and which are not logical address 0, slot 0, or external controllers.
error in describes error conditions that occur before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurs before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.
code is the error or warning code. The default is 0. If status is TRUE, code is a non-zero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.
find list is an array of strings, each string specifying one interface found by the function.
return count specifies the number of matches found. The number of matches found is the number of strings in the find list array.
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out indicator on the front panel and select Explain Error from the shortcut menu for more information about the error.
status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.
code is the error or warning code. If status is TRUE, code is a non-zero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning.