Variable assignment in if statements
Posted: Tue Aug 05, 2014 9:23 am
Hello,
I have encountered some unexpected behavior when assigning a variable in an if statement. Consider the following minimal working example, which checks to see if a variable was passed via a -c command line argument:
I receive the following unexpected output:
However, when I comment out the assignment within the if statement, I see the expected output:
I saw the post here and am currently using the workaround of passing a substitute variable name as is done here, but thought I should report the bug regardless in case it is unknown. I saw nothing in the documentation on the subject and could not find a bugtracker.
I am running NEURON "VERSION 7.3 ansi (1078:2b0c984183df) 2014-04-04", compiled from source using the "--with-nrnpython" and "--paranrn" compiler flags on GNU/Linux x86_64, 3.2.0-29-generic.
I have encountered some unexpected behavior when assigning a variable in an if statement. Consider the following minimal working example, which checks to see if a variable was passed via a -c command line argument:
Code: Select all
print name_declared("myparam")
if (name_declared("myparam")!=5) {
print "Case 1"
myparam = 3
} else {
print "Case 2"
}
Code: Select all
0
Case 2
Code: Select all
0
Case 1
I am running NEURON "VERSION 7.3 ansi (1078:2b0c984183df) 2014-04-04", compiled from source using the "--with-nrnpython" and "--paranrn" compiler flags on GNU/Linux x86_64, 3.2.0-29-generic.