Getting a error ""invalid command name "elseif"

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
jndlsmt
Posts: 18
Joined: Thu Nov 25, 2010 2:37 am
Location: IIT Kanpur

Getting a error ""invalid command name "elseif"

Post by jndlsmt »

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
Sumit Jindal
IIT Kanpur (India)
sb1966
Posts: 151
Joined: Wed Jul 23, 2008 8:08 am
Location: NERIST, INDIA
Contact:

Re: Getting a error ""invalid command name "elseif"

Post by sb1966 »

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
sb1966
Posts: 151
Joined: Wed Jul 23, 2008 8:08 am
Location: NERIST, INDIA
Contact:

Re: Getting a error ""invalid command name "elseif"

Post by sb1966 »

I mean u r using nested elseif blocks
----------------------------------
With Regards,
sb1966
jndlsmt
Posts: 18
Joined: Thu Nov 25, 2010 2:37 am
Location: IIT Kanpur

Re: Getting a error ""invalid command name "elseif"

Post by jndlsmt »

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
}
}}
Sumit Jindal
IIT Kanpur (India)
sb1966
Posts: 151
Joined: Wed Jul 23, 2008 8:08 am
Location: NERIST, INDIA
Contact:

Re: Getting a error ""invalid command name "elseif"

Post by sb1966 »

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.
----------------------------------
With Regards,
sb1966
jndlsmt
Posts: 18
Joined: Thu Nov 25, 2010 2:37 am
Location: IIT Kanpur

Re: Getting a error ""invalid command name "elseif"

Post by jndlsmt »

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"
Sumit Jindal
IIT Kanpur (India)
sb1966
Posts: 151
Joined: Wed Jul 23, 2008 8:08 am
Location: NERIST, INDIA
Contact:

Re: Getting a error ""invalid command name "elseif"

Post by sb1966 »

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
Post Reply