Run sequentially cir and net files with tcl/tk

202 Views Asked by At

I would like to give me your advice about using cadence orcad so I can run sequentially cir or net(netlist) files with pspice.exe in cmd of my pc.

I use tcl/tk language.I have tried a few things without any results.

I want to make something similar to this one:

set top  {C:\Users\file1.net C:\Users\file2.net}; 
foreach a $top 
{exec D:\\tools\\bin\\pspice.exe -r $a}
2

There are 2 best solutions below

6
Donal Fellows On BEST ANSWER

There are two problems in your code. The first problem is that \f is an escape character sequence in lists (for “go down one line”, IIRC; point is you don't want that interpretation). The second problem is that you've got your brace placement wrong in your foreach.

The first problem is best addressed by using / instead of \, and then using file nativename on the value fed to the OS. (You have to do that manually for argument to executables in expr; Tcl can't fix that for you entirely automatically.) The second problem is just a syntax error.

Try this:

set top {C:/Users/file1.net C:/Users/file2.net}
set pspice D:/tools/bin/pspice.exe
foreach a $top {
    # Tcl knows how to convert executable names for you; not the other args though
    exec $pspice -r [file nativename $a]
}
0
AudioBubble On

On Windows you may also try:

package require twapi

set top {C:/Users/file1.net C:/Users/file2.net}

foreach a $top {
    twapi::shell_execute -path [file nativename $a]
}

This will work only if *.net files are already associated with PSpice application.

The code above rely on TWAPI extension (if you have it) and its shell_execute function, to open a document just like double-click works.

It's always a good idea to avoid backslashes in your code (no need to put it twice to escape them), file nativename will do the job for you.

Source: https://twapi.magicsplat.com/v4.5/shell.html#shell_execute