We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 62015

Vivado - Can I source a Tcl script and also pass command line arguments to the script?


I have a Tcl script I wish to use in Vivado.  

If I source the script and add command line arguments after it, I get an error message that I have too many positional options when calling the script.

For Example:

source example.tcl hello

ERROR: [Common 17-165] Too many positional options when parsing 'hello', please type 'source -help' for usage info.

Is it possible to provide command line arguments to a script, and how do I do it?


This error occurs because the source command to run the script only expects a single argument.  

It is not possible to add the options to the source call.

However, it is possible to get and set variables so that the script is compatible with the standard command line calls for Tcl scripts.

For example:

Start with a very simple script called example.tcl:

#example.tcl source code below

puts "The total number of arguments is $argc"
if {$argc > 0} {puts "The arguments in ARGV are: $argv" }

#end script example.tcl

You then need to populate the command line arguments yourself.

set argv [list Hello World]
set argc 2

This allows the script to be called as follows:

source example.tcl
The final result should look like the following:
set argv [list Hello World]
set argc 2
source example.tcl

The total number of arguments is 2"
The arguments in ARGV are: Hello World




AR# 62015
Date 01/14/2015
Status Active
Type General Article
  • Vivado Design Suite
Page Bookmarked