TCL help needed... Urgent!!

Status
Not open for further replies.

Sumitha Sudhakaran

Junior Member level 2
Joined
Aug 7, 2012
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bangalore
Activity points
1,440
Suppose i have a tcl file to be run, say test.tcl.. and i want to specify the file to be tested, say test.tcl file1. wha do i do to extract "file1" from the command line and perform the test on the file.. i need a tcl command, that helps extract the argument from the command line..
 


All Tcl scripts have access to three predefined variables.
$argc - number items of arguments passed to a script.
$argv - list of the arguments.
$argv0 - name of the script.

Code:
puts "Script Name is" 
puts [lindex $argv0] 
puts "second Argument is"
puts [lindex $argv 0]
puts "Third Argument is"
puts [lindex $argv 1]


Eg.
Code:
tclsh argtest.tcl myarg1 myarg2



output
Script Name is
argtest.tcl
second Argument is
myarg1
Third Argument is
myarg2
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…