#!/bin/sh
# This is a trial program
puts "++++++++++++++++++++++++++++++++++++++++++++++++++"
set y "0.0.0.0"
set z [split $y "."]
puts "z=$z"
lreplace $z 0 5
puts "z $z"
set v [llength $z]
puts "length of array= $v"
puts "in the loop-------->\n"
puts " "
incr v -1
puts $v
for {set ml $v } { $ml >= 0} { puts "$ml =ml"} {
for { set nl [lindex $z $ml]} { $nl >=4} { puts "$nl=nl"} {
puts $nl
after 2000
lset z $ml $nl
incr $nl
}
after 2000
incr ml -1
}
I am not able to enter the second for loop, is this a formatting issue ? gives me some weird error. I added the sleep just to check whats happening so ignore that.
lreplace $z 0 5?lreplace $z 0 5doesn't actually do anything in this program. The command creates a result list based on the elements in z with all those elements up to (non-existent) index 5 deleted, and then you don't assign this result list anywhere.set z [lmap elem $z { expr { $elem == 0 ? 5 : $elem } }]incr nlnotincr $nl