if (do_name() != 'Home') : ?>
endif ?>
Posted by _brentonW on Jun 12, 2009
Thoughts/suggestion?
A bit of digging around nodebox revealed that I had the syntax wrong. I believe I have corrected that however am unable to prove it by a simple print action.
Example
for i in range(9): [code to run 9x] if (i == range): print "true"While I am able to syntactically set up the "if" statement it doesn't run.
Thoughts/suggestion?
Posted by Stefan on Jun 12, 2009
This won't work because you're comparing a number (i) to a function (range). The two can be compared however they will always return False.
Since the function range generates a list of numbers, what you really want to do is compare i to to some item in this list, the last item in your case. The last item in a list is somelist[-1]
So the code becomes something like this:
myrange = range(9) for i in myrange: # code to run 9x if i == myrange[-1]: print "true"
Posted by Lucas on Jun 12, 2009
Or this way, remember the range starts counting from zero.
anynumber = 9 for i in range(anynumber): print "coderun:", i + 1 if i + 1 == anynumber: print "the last run: ", i + 1
Posted by _brentonW on Jun 14, 2009
include("util/comment.php"); ?>
ahhh.
I see.
Thanks for the help.
Really appreciate it.
conditionals :: absolute equality
Posted by _brentonW on Jun 12, 2009Can anyone tell me if nodebox allows the equality operator [ == ]? or an alternate for an if statement?
I want to run some code at the end of a "for" statement with an "if" statement to run when [ i ] and 'range' are equal.
Using the "==" equality symbol throws an error.
Any suggestion to an alternate solution would be appreciated.
Example: