Pages

Thursday, November 20, 2014

How to comment multiple lines in TCL

1st method :

# sadhfkhfksd \
sdfjkljdsf \
afls;dfksd \
asfj;lkgfsd \

sdfsdkgj

2nd method:

if {0} {
----
---
---
}


Tuesday, November 4, 2014

parser proc in tcl

proc args_parser {args} {
    set length [llength $args]
    puts "Length of the args is $length"
    for { set i 0 } { $i < $length } { incr i } {
        set arg_name [lindex $args $i]
        incr i
        set arguments($arg_name) [lindex $args $i]
    }
    return [array get arguments]
}

proc b {args} {
    array set ar [eval args_parser $args]
    set name $ar(-name)
    set age $ar(-age)
    set country $ar(-country)
    set location $ar(-location)
    puts "$name is aged $age\n";
    puts "$name is located at $location,$country\n";
}

b -name nawraj -age 30 -location bangalore -country India