user2314818
user2314818

Reputation: 51

how to pass parameter while sourcing script file

i was sourcing a tcl script file and could not pass the parameter. ie.

source test.tcl param1 param2

where in test.tcl, it uses param1 and param2 to print as string

Note: I need to source tcl script only.. Not any other

puts "param1                       :  $1"
puts "param2                       :  $2"

Upvotes: 1

Views: 355

Answers (1)

Brad Lanam
Brad Lanam

Reputation: 5733

You can set argv:

set origargv $::argv
set ::argv [list -param1 x -param2 y]
source myscript

The sourced script can access the parameters from argv as usual.

Upvotes: 2

Related Questions