Getting a error ""invalid command name "elseif"
Moderators: silvia, selimgunay, Moderators
Getting a error ""invalid command name "elseif"
hi all,
i am getting an error while generating a node or elements by loops..........
this is my code ............
for {set i 1} {$i<=$nodeTotal} {incr i 1} {
##--left end portion
if {$i >= 1 && $i <= [expr $ndivEnd+1]} {
node [expr 1000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--right end portion
#elseif {$i <= $nodeTotal && $i >=[expr ($nodeTotal-$ndivEnd)]} {
elseif {$i >= [expr ($nodeTotal-$ndivEnd)] && $i <= $nodeTotal} {
node [expr 1000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
node [expr 100000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
fix [expr 100000+$i] 1 1 1
}
##--mid portion
elseif {$i > [expr $ndivEnd+1] && $i < [expr $nodeTotal-$ndivEnd]} {
node [expr 1000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--nodes created for horizontal springs
if {$i==$nodeTotal} {
node [expr 100000+$i+1] [expr $Lfoot/2] 0.0
node [expr 100000+$i+2] [expr $Lfoot/2] 0.0
fix [expr 100000+$i+1] 1 1 1
fix [expr 100000+$i+2] 1 1 1
}
}}
please correct me ....
thanks in advance
i am getting an error while generating a node or elements by loops..........
this is my code ............
for {set i 1} {$i<=$nodeTotal} {incr i 1} {
##--left end portion
if {$i >= 1 && $i <= [expr $ndivEnd+1]} {
node [expr 1000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--right end portion
#elseif {$i <= $nodeTotal && $i >=[expr ($nodeTotal-$ndivEnd)]} {
elseif {$i >= [expr ($nodeTotal-$ndivEnd)] && $i <= $nodeTotal} {
node [expr 1000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
node [expr 100000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
fix [expr 100000+$i] 1 1 1
}
##--mid portion
elseif {$i > [expr $ndivEnd+1] && $i < [expr $nodeTotal-$ndivEnd]} {
node [expr 1000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--nodes created for horizontal springs
if {$i==$nodeTotal} {
node [expr 100000+$i+1] [expr $Lfoot/2] 0.0
node [expr 100000+$i+2] [expr $Lfoot/2] 0.0
fix [expr 100000+$i+1] 1 1 1
fix [expr 100000+$i+2] 1 1 1
}
}}
please correct me ....
thanks in advance
Sumit Jindal
IIT Kanpur (India)
IIT Kanpur (India)
Re: Getting a error ""invalid command name "elseif"
I think your first elseif{..} {..} block is redundant (not doing anything) as u have not provided any code there. May be this is the problem.
----------------------------------
With Regards,
sb1966
With Regards,
sb1966
Re: Getting a error ""invalid command name "elseif"
I mean u r using nested elseif blocks
----------------------------------
With Regards,
sb1966
With Regards,
sb1966
Re: Getting a error ""invalid command name "elseif"
thanks for reply
actually i copied comment line also....
so corrected one is............
hi all,
i am getting an error while generating a node or elements by loops..........
this is my code ............
for {set i 1} {$i<=$nodeTotal} {incr i 1} {
##--left end portion
if {$i >= 1 && $i <= [expr $ndivEnd+1]} {
node [expr 1000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--right end portion
elseif {$i >= [expr ($nodeTotal-$ndivEnd)] && $i <= $nodeTotal} {
node [expr 1000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
node [expr 100000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
fix [expr 100000+$i] 1 1 1
}
##--mid portion
elseif {$i > [expr $ndivEnd+1] && $i < [expr $nodeTotal-$ndivEnd]} {
node [expr 1000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--nodes created for horizontal springs
if {$i==$nodeTotal} {
node [expr 100000+$i+1] [expr $Lfoot/2] 0.0
node [expr 100000+$i+2] [expr $Lfoot/2] 0.0
fix [expr 100000+$i+1] 1 1 1
fix [expr 100000+$i+2] 1 1 1
}
}}
actually i copied comment line also....
so corrected one is............
hi all,
i am getting an error while generating a node or elements by loops..........
this is my code ............
for {set i 1} {$i<=$nodeTotal} {incr i 1} {
##--left end portion
if {$i >= 1 && $i <= [expr $ndivEnd+1]} {
node [expr 1000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--right end portion
elseif {$i >= [expr ($nodeTotal-$ndivEnd)] && $i <= $nodeTotal} {
node [expr 1000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
node [expr 100000+$i] [expr $Lfoot/2 +($i-$nodeTotal)*$LendEle] 0.0
fix [expr 100000+$i] 1 1 1
}
##--mid portion
elseif {$i > [expr $ndivEnd+1] && $i < [expr $nodeTotal-$ndivEnd]} {
node [expr 1000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*$ndivEnd+($i-$ndivEnd-1)*$LmidEle-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
}
##--nodes created for horizontal springs
if {$i==$nodeTotal} {
node [expr 100000+$i+1] [expr $Lfoot/2] 0.0
node [expr 100000+$i+2] [expr $Lfoot/2] 0.0
fix [expr 100000+$i+1] 1 1 1
fix [expr 100000+$i+2] 1 1 1
}
}}
Sumit Jindal
IIT Kanpur (India)
IIT Kanpur (India)
Re: Getting a error ""invalid command name "elseif"
Dear Sumit,
You must place the elseif block on the same line where the if block ends. This is in order to defer command substitution until relevant expressions are evaluated. Refer to p 73 of Ousterhout, J. K., Tcl and Tk Toolkit, Addison Wesley, 1994. This is a feature of Tcl language. So your script should be like this:
for {set i 1} {$i<=$nodeTotal} {incr i 1} {
##--left end portion
if {$i >= 1 && $i <= [expr $ndivEnd+1]} {
node [expr 1000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
} elseif {$i >= [expr ($nodeTotal-$ndivEnd)] && $i <= $nodeTotal} {
##--right end portion
...
...
Hope this helps.
You must place the elseif block on the same line where the if block ends. This is in order to defer command substitution until relevant expressions are evaluated. Refer to p 73 of Ousterhout, J. K., Tcl and Tk Toolkit, Addison Wesley, 1994. This is a feature of Tcl language. So your script should be like this:
for {set i 1} {$i<=$nodeTotal} {incr i 1} {
##--left end portion
if {$i >= 1 && $i <= [expr $ndivEnd+1]} {
node [expr 1000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
node [expr 100000+$i] [expr $LendEle*($i-1)-$Lfoot/2] 0.0
fix [expr 100000+$i] 1 1 1
} elseif {$i >= [expr ($nodeTotal-$ndivEnd)] && $i <= $nodeTotal} {
##--right end portion
...
...
Hope this helps.
----------------------------------
With Regards,
sb1966
With Regards,
sb1966
Re: Getting a error ""invalid command name "elseif"
thanks sb1966
if you have ebook of "Tcl and the Tk Toolkit "
please give me the downloading link or mail it to me. my mail id is "sjindal@iitk.ac.in"
if you have ebook of "Tcl and the Tk Toolkit "
please give me the downloading link or mail it to me. my mail id is "sjindal@iitk.ac.in"
Sumit Jindal
IIT Kanpur (India)
IIT Kanpur (India)
Re: Getting a error ""invalid command name "elseif"
Sorry, I do not have the e-book. But selected chapters of "Practical Programming in Tcl-Tk" by Brent Welsh can be downloaded from http://morrorservice.org/sites/ftp.tcl.tk/pub/welsh/
----------------------------------
With Regards,
sb1966
With Regards,
sb1966