linsert in recursive list
 
Post new topic   Reply to topic    Hawkee.com Forum Index -> TCL Scripting
 
jamshid  -  Tue Jun 14, 2011 6:56 pm Reply with quote
Hi all,

I have written a code to get the index of recursive lists:
set a {a b {c {d e}}}
proc recList{list_name {prefix {}}} {
set end_point [expr [llength $list_name] -1]
for {set start_point 0} {$start_point <= $end_point} {incr start_point} {
if {[llength [lindex $list_name $start_point]] == 1} {
puts "Index for [lindex $list_name $start_point] is $prefix$start_point"
} else {
append prefix $start_point
recList[lindex $list_name $start_point] $prefix
}
}

Now in this i want insert some elements inside, how can i do that.
Eg: This is how the program should look like
puts "Enter element"
gets stdin el { user enters as 4 }
puts "Enter insert posittion"
gets stdin ind { user gives as 210}
So if 210 index is valid in the list the new element should be inserted and if the user gives ind as something like 530 it should display "error in index entered"..
How can i do this?
Please help.

Thanks in advance
Display posts from previous:   
Post new topic   Reply to topic    Hawkee.com Forum Index -> TCL Scripting All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.