-2

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}
tripleee
  • 175,061
  • 34
  • 275
  • 318
paiktis30
  • 3
  • 3
  • What's wrong with the current attempt? Where exactly are you stuck? – tripleee Apr 26 '21 at 12:09
  • That code isn' t running and to clarified it better I want to make that procedure : set top {C:\Users\new.net}; exec D:\\tools\\bin\\pspice.exe -r $top , for a few files. – paiktis30 Apr 26 '21 at 13:11

2 Answers2

0

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]
}
Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • Use “Ancient Egyptian” braces with Tcl unless you either know _exactly_ what you're doing, or really like fighting with the base language syntax. – Donal Fellows Apr 26 '21 at 13:54
  • I found your first problem by looking at what `lindex $top 0` returned. – Donal Fellows Apr 26 '21 at 13:56
  • Firstly thank you for your answer.Secondly the code above run and simulate only the first file of our list and that's the problem which I come up against.For example i want to make 20 *.net files to run and simulate under of pspice.exe from my cmd. – paiktis30 Apr 26 '21 at 18:12
  • @paiktis30 Put a `&` at the end of `exec` line, like this: `exec $pspice -r [file nativename $a] &` –  Apr 26 '21 at 18:55
  • @Losko thank you for your anwser, that correction it works,but only for the first file of my list. – paiktis30 Apr 26 '21 at 19:44
  • Ok. Have you tried what I wrote in the other answer? If you are able to open multiple documents inside PSpice (using Windows Explorer I mean) then you should give it a try, that's the closest thing possible... what happens normally if you double click on `*.net` files? TWAPI solution simulates exactly that behavior. –  Apr 26 '21 at 20:14
0

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