LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

a regular expression to obtain a GPIB address from a VISA resource string

I have a VISA resource string formatted as such:
GPIB[bd]::prim addr[::sec addr]

All I want to obtain is the prim addr. Basically I want a regular expression that will grab what is between the 2nd colon and the end of the string or between the 2nd colon and an opening left bracket.
Both these cases are needed because the brackets indicate optional parameters and might not actually be present in the string.
Any help or suggestions would be fantastic.

Thanks,
Jimbo
0 Kudos
Message 1 of 6
(3,791 Views)
I think the trick here is to use the "Match Pattern" vi and get everything between the colons. I have a small library vi for just this type of operation (I have attached it here). This vi will return everything between the 2 delimiters. Connect a string constant containing the colons ("::") to both delimiter inputs and the VISA resource string to the string input. Yes, you can connect a VISA resource to string functions.

Rob
0 Kudos
Message 2 of 6
(3,791 Views)
If you just want the address, you could also use a VISA property node - GPIB Settings>Primary Address.
0 Kudos
Message 3 of 6
(3,791 Views)
This idea did occur to me but I'm not sure if I went about it correctly...
I right clicked my I/O control in the block diagram(which I had created by placing a VISA resource name menu on the front panel)
After right-clicking it I selected create>>property node. But under the properties of the property node I didn't find anything like GPIB settings.
Could it have something to do w/ what is checked under Select VISA class?(for the VISA resource name control - not the property node) All that is checked under there right now is Select VISA class>>I/O Session>>instr Or did I just create the wrong property node?

Jim
0 Kudos
Message 5 of 6
(3,791 Views)
Hey nevermind my previous comment - I just found the property node you were referring to. Thanks!

Jim
0 Kudos
Message 6 of 6
(3,791 Views)
Hi,

If you are using LabVIEW 6.0.x, which I guess you are, try this:

take the output of the VISA Resource control and feed it to the Flatten to String function. The output will give you your old pre labview6 resource string. ( you will need to ignore the 4 byte char count).

See attached VI. ( I have just done a simple strip the numbers out of the string in the example)

(Dennis's answer quite good as well)
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 6
(3,790 Views)