Error! - TCL

This is a discussion on Error! - TCL ; Hi all, I urgently need your help,guys! Here is my coding to convert hex2bin and display them bit by bit. proc hex2bin hex { set b { 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 ...

+ Reply to Thread
Results 1 to 2 of 2

Error!

  1. Default Error!

    Hi all,

    I urgently need your help,guys!
    Here is my coding to convert hex2bin and display them bit by bit.


    proc hex2bin hex {

    set b { 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 a 1010 b 1011 c 1100 d 1101 e 1110 f 1111 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111}

    regsub {^0[xX]} $hex {} hex
    regsub -all . $hex {$b(&)} hex2bin_binary
    return [subst $hex2bin_binary]
    #return [string map -nocase $b $hex]

    }



    set input_file [ open "\\Tcl\\bin\\list.csv" "r+" ]
    set output "out.txt"
    set output_file [open "$output" "w+"]

    while {[gets $input_file input_line] >= 0} {


    set input_line [split $input_line ","]


    if {[regexp [lindex $input_line 3] "h"] == 1} {

    set temp [split[lindex $input_line 1] ""]

    for {set i 0} {$i< [llength $temp]} {incr i} {

    append value [hex2bin[lindex $temp $i]]
    }
    } else {
    set value [lindex $input_line 1]
    }

    set value [split $value ""]

    set signal_name [lindex [split [lindex $input_line 0] {[} ] 0]

    if {[regexp [lindex $input_line 0] ":"] ==1 } {

    set j [lindex [split [lindex [split [lindex $input_line 0] {:}] 1] {]}] 0]
    } else {}


    #set k [lindex [split [lindex [split [lindex $input_line 0] {:}] 0] {[}] 1]

    for {set i 0} {$i < [lindex $input_line 2]} {incr i} {

    if {[lindex $input_line 2] > 1} {

    puts $output_file "[lindex $value [expr [lindex $input_line 2] -$i -1]] ${signal_name}\[[expr $i + $j]\]"

    } else {

    puts $output_file "$value $signal_name"

    }

    }

    }

    close $input_file

    close $output_file


    However, there is an error:
    invalid command name "split0"

    I hope that you guys can help me...thanks!

  2. Default Re: Error!

    The only problem I see is that the digits are not lined up correctly.

+ Reply to Thread

Similar Threads

  1. Error: Windows SDK function returned an error. (Error code -12)
    By Application Development in forum labview
    Replies: 3
    Last Post: 05-13-2008, 09:10 AM
  2. Replies: 1
    Last Post: 03-05-2008, 12:24 PM
  3. Replies: 2
    Last Post: 09-13-2007, 07:10 AM
  4. Can't Save File Error, I/O error, Program Error
    By Application Development in forum Adobe Photoshop
    Replies: 11
    Last Post: 12-11-2006, 09:21 AM
  5. Replies: 0
    Last Post: 08-09-2004, 04:30 AM