Procedure opening/closing brackets
How exactly do these work?? I've noticed that sometimes you don't even need them at all, and sometimes they're just as important as you think.
Magic voodoo.
The DinkC script parsing is not very understandable. My advice is to code as best as you can, and use curly braces everywhere.
The DinkC script parsing is not very understandable. My advice is to code as best as you can, and use curly braces everywhere.
My general policy is that if you only have one statement below the "if()", you don't need brackets. Any more than that, and I use them. I have yet to have a problem with this method.
Well, when the body of the if-statement is only one command/expression/whatever, you don't necessarily need them because that's part of the syntax. But the body can also have more commands/expressions/etc and then you need them because otherwise, the engine/compiler doesn't know they're all part of the body of the if-statement
We're doing that @ uni these days so that's why You can consistently use brackets only when necessary (so not when there's only 1 thing in the if-statement's body) but on the other hand, it's generally better to use them everywhere because you can see at all times what starts and ends where (and, if you wanted to add something else, you'd need to add those brackets again to make sure it functions properly - and, when you forget that, you'd wonder why it's not working right )
We're doing that @ uni these days so that's why You can consistently use brackets only when necessary (so not when there's only 1 thing in the if-statement's body) but on the other hand, it's generally better to use them everywhere because you can see at all times what starts and ends where (and, if you wanted to add something else, you'd need to add those brackets again to make sure it functions properly - and, when you forget that, you'd wonder why it's not working right )
That works, except when assigning variables.
This doesn't work:
if (&bob == 3) &bob = 4;
This doesn't work:
if (&bob == 3) &bob = 4;
What about?
if (&bob == 3)
&bob = 4;
if (&bob == 3)
&bob = 4;
Magic voodoo.
Hmm, yeah, I was just wondering after realizing scripts with only main() didn't need
void main()
{
}
Hmm, yeah, I was just wondering after realizing scripts with only main() didn't need
void main()
{
}
I use that policy too. It's annoying using brackets especially for multiple if()'s and one-liners in a row. I get the feeling my script's more bound to randomly crash without the brackets, though. Superstition... may be. ^^
I don't remember... I was just looking through a DinkC script, and I used something very similar, but it worked.
So I could be spreading falsehoods out to corrupt the minds of Dink developers, hmm.
So I could be spreading falsehoods out to corrupt the minds of Dink developers, hmm.
Hmm, if
if (&bob == 3) &bob = 4;
doesn't work, then Striker's example shouldn't work either because it's basically the same syntax except using 1 more line - you could write a whole program (not a DinkC script, DinkC is very limited ) on 1 line but that wouldn't be readable for us Or perhaps DinkC has odd logic and redink1's example doesn't work, and Striker's example does
if (&bob == 3) &bob = 4;
doesn't work, then Striker's example shouldn't work either because it's basically the same syntax except using 1 more line - you could write a whole program (not a DinkC script, DinkC is very limited ) on 1 line but that wouldn't be readable for us Or perhaps DinkC has odd logic and redink1's example doesn't work, and Striker's example does
Or perhaps DinkC has odd logic and redink1's example doesn't work, and Striker's example does
Yeah, when you put them on separate lines it works. Multiple commands on the same line don't work nearly as often.
Yeah, when you put them on separate lines it works. Multiple commands on the same line don't work nearly as often.
Yeah in Dinkc.txt Seth writes the following:
DinkC PARTLY supports multiple commands per line, but later I decided not
to pursue it.. was eating up too much processer time with my slow searches..
So this is a large difference between C and DinkC.
DinkC PARTLY supports multiple commands per line, but later I decided not
to pursue it.. was eating up too much processer time with my slow searches..
So this is a large difference between C and DinkC.