Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ending script execution

Status
Not open for further replies.

MarcioCardoso

Technical User
Apr 14, 2003
1
0
0
CA
Hi,
I run a Tcl script from TestStand SW(National Instruments).
In my script, I frequently test a variable which determines if the script execution should terminate or not.

Using "exit" command causes a Run-Time Error in the TestStand.

How can I finalize my script execution without use "exit" command? How can I go to end of script?

Thanks
Marcio
 
In a standard Tcl interpreter, exit shouldn't cause an error like that, so it sounds as though TestStand is doing something non-standard. Your best bet is to check the TestStand documentation (or call their tech support) to find out the recommended method for terminating a script.

If you can't find an answer from those sources, you can still code around the problem with Tcl, but it isn't the most intuitive of approaches. Tcl has no goto command. So, I've seen some people wrap their code in a loop construct like while -- even though their intent is to execute the code block only once -- and then explicitly break from the loop at appropriate points. (Personally, I've never used the approach, because I've always found some more intuitive way to structure my code. But necessity sometimes calls for innovation.) Just remember to break at the bottom or your code will keep on looping. For example:

while {1} { # Begin code block

# Do some processing

if {$test} { break } ;# Goto end

# Do more processing

if {$test2} { break } ;# Goto end

# Etc...

break ;# End code block
}[/code]

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Marcio,
Have you seen the sample Tcl script ni provides?
seems like the mechanism to return control to test stand is by means of an output variable defined in the sequencer.

Then, whenever Tcl sets the variable, control is returned to test stand.

Jicote.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top