As far as I know it already does. (just not all in one word)
_Code:IF Condition then Something else if Condition2 then something else endif endif
As far as I know it already does. (just not all in one word)
_Code:IF Condition then Something else if Condition2 then something else endif endif
DT
That's not the same. True ELSEIF structure will exit out of the nest as soon as it hits the first true condition. Same as Select Case.
But PBP doesn't have the virtually (pun intended) unlimited stack space like Windows does.
Gotta draw the line somewhere I suppose.
What I'm saying is that multiple IF/THEN statements:
IF this then
that
ENDIF
IF this then
that
ENDIF
made back-to-back-to-back, takes more flash space than successive IF/THEN statements:
If this then
if this then
if this then
that
endif
endif
EndIf
I had to use the successive version of the IF/THEN vs. the back-to-back version in my MP3 player in a number of places (no way around it due to how the program was set up, either it was bad style or I just had too much going on to keep tabs on, just the nature of the program's complexity). Anywhos...when I changed everything over to the successive type, I saved a load of code space. I never did check in to why I saved as much space as I did, it just did, and I'm happy.
As far as stack space goes, are you saying that there aren't any calls involved with doing an if/then?
It's not the same if a multitude of ELSEIF is required ...
I guess you could have a GOTO in each block to exit out of the nest - but as I said before, true ELSEIF would make a nice addition to PBP.Code:IF Condition then Something else if Condition2 then 'ELSEIF 1 something else endif '// Even if ELSEIF 1 is true then we still validate this argument if Condition2 then 'ELSEIF 2 something else endif '// Likewise, even if ELSEIF 2 is true then we still validate this argument if Condition3 then 'ELSEIF 3 something else endif endif
<hr/>
It'll work. You just need to add the next condition in the last one's ELSE clause.Code:IF Condition then Something else if Condition2 then something else else if Condition3 then even more else if Condition4 then 4's good else this is the final ELSE, if none of the others match it ends up here endif endif endif endifCorrect. If/Thens don't use the stack. They use GOTO's only.Originally Posted by skimask
Added: There is no limit to the "Nested" levels of IF/THEN's.
_
Last edited by Darrel Taylor; - 9th May 2007 at 18:25. Reason: Nested Levels
DT
O.K. I agree that to be logically equivalent to ELSEIF. But there's one downside, how do you plan on indenting 20 or more nested arguments?
But, you have clearly illustrated just how easy it would be for MELABS to implement support for ELSEIF. PBP already has the raws required.
Last edited by T.Jackson; - 10th May 2007 at 03:38.
no problem, i use a dual screen video card and two monitor![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
That's just the way I format things.Originally Posted by T.Jackson
You dont have to do it that way.
Here's one that skimask will like. (lottsa colons)Code:IF Condition then Something else:IF Condition2 then something else else:if Condition3 then even more else:if Condition4 then 4's good else this is the final ELSE, if none of the others match it ends up here endif:endif:endif:endif
DT
You're missing the point. While I agree that what you're saying will indeed do the same job (regardless of how you format it) there's still more effort from the programmer that's required. There's additional thought process along with extra typing. And, I have a sneaking suspicion that traditional ELSEIF structures might be somewhat better optimized.
Bookmarks