Hello,
I am getting back into Tcl after many years and am struggling how to make up a
command. The script is used to communicate with a voltmeter using a visa library.
This code works:
set rm [visa::open-default-rm]
set inst [visa::open $rm "GPIB0::22::INSTR"]
The "22" in the inst variable is the meter's GPIB address. With the rest of the code,
I can capture readings, save them to a file etc.
What I am trying to figure out is how to get this line formatted to be able to
use an entry box feeding a variable named gpib. I can get the variable populated
via the entry box, but getting the variable contents to work in the set inst command
is giving me trouble.
This does -not- work:
set gpib 22 (via the entry box)
set rm [visa::open-default-rm]
set inst [visa::open $rm "GPIB0::$gpib::INSTR"]
I'm thinking maybe using the format command is the key, but can't figure it out.
any thoughts?
Thanks!
Bob
set gpib 22 (via the entry box)
set rm [visa::open-default-rm]
set inst [visa::open $rm "GPIB0::$gpib::INSTR"]
I'm thinking maybe using the format command is the key, but can't figure it out.
any thoughts?
Bob Liesenfeld <user21406@newsgrouper.org.invalid> wrote:
set gpib 22 (via the entry box)
set rm [visa::open-default-rm]
set inst [visa::open $rm "GPIB0::$gpib::INSTR"]
I'm thinking maybe using the format command is the key, but can't figure it out.
any thoughts?
et99 gave you the solution to your code above.
If you prefer the format command instead it would be:
set inst [visa::open $rm [format "GPIB0::%d::INSTR" $gpib]]
* Bob Liesenfeld <user21406@newsgrouper.org.invalid>Thanks to all for the help! Script working fine now. Also, Ralf, >great< point
| This does -not- work:
| set gpib 22 (via the entry box)
| set rm [visa::open-default-rm]
| set inst [visa::open $rm "GPIB0::$gpib::INSTR"]
In addition to what others already contributed, it is always a good idea
to include any error message or diagnostic in the question - even a
"nothing happens at all" (an error dialog popping up or a message on the console is NOT nothing) helps others to rule out possible causes.
R'
http://www.catb.org/~esr/faqs/smart-questions.html
Hello,...
I am getting back into Tcl after many years and am struggling how to make up a
command. The script is used to communicate with a voltmeter using a visa library.
This code works:
set rm [visa::open-default-rm]
set inst [visa::open $rm "GPIB0::22::INSTR"]
The "22" in the inst variable is the meter's GPIB address. With the rest of the code,
I can capture readings, save them to a file etc.
set gpib 22 (via the entry box)
set rm [visa::open-default-rm]
set inst [visa::open $rm "GPIB0::$gpib::INSTR"]
I'm thinking maybe using the format command is the key, but can't figure it out.
any thoughts?
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 74 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 46:35:12 |
| Calls: | 1,100 |
| Files: | 1,339 |
| Messages: | 275,543 |