Running a tcl script with relative paths

  • Hello,

    my problem is related to a tcl script which automates the simulation of a design. The mentioned script has to open and store some files.

    While developping this script I set a constant to the desired working directory. Execution of the script is triggered through a shell command in third party software.

    Now I would like to run on relative paths to ensure portability. To achieve this, the 'pwd' command is used to build full qualified paths. I changed the shell command like that:

    start /b /wait "" /d "(the desired working dir)" "%VASINSTALLDIR%\Bin\VisualApplets.exe" -file vaSimulationScript.tcl

    This does not work because VA uses it's own working path.

    I searched for a shell parameter to set VA to the desired working directory, but I found none.

    So I tried to let my Software create a temporary tcl, which is like this:

    MakeDirectoryPath "(the desired working dir)"
    Source "(the desired working dir)/vaSimulationScript.tcl"

    Even with this Method the working directory in the tcl is wrong.

    What should I do?

    Thank you



  • Hi Simon

    welcome to the forum. Before searching for a solution based on TCL maybe another feature will help you: Did you notice a new setting for the location of simulation image files:


    It is available from VA 3.1.0

    Maybe that'll help you.

    Other than that you need to build absolute paths for all simulation images when adding them to the simulation. Note that you can use regular expressions within the TCL.


    Johannes Trein
    Group Leader R&D
    frame grabber

    Basler AG

  • Hi Johannes,

    thank you for your reply.

    I need to load some settings out of (Text-)files for testing the Design. Unfortunately, changing the Image sources to relative paths does not help.

    Every time VA is called with my tcl script another set of images and settings is loaded/applied, the design simulated and the output stored.

    In one static settings file (which is altered by other software) are the paths to the files for the specific test set. And this file is the only thing I need to load with relative paths in the tcl script to be portable.

    Maybe there is another way to achieve this?

    Thank you

  • Hi Simon,

    I use TCL for Applet generation. For that I created a folder with TCL scripts. When I run my base script I set the base folder to the folder the script is in and after that I run relatively from that path.

    You can do that using this code in your main TCL-Script.

    cd [file dirname [info script]]

    after setting the path to the known folder can be done relativly using the cd command.For example if your image folder would be one folder up and than named image

    cd ../image

    I hope that helps you to archieve your goal.

    best regards


  • Superman

    Added the Label Resolved