Can I always use brackets?

Blitz3D Forums/Blitz3D Beginners Area/Can I always use brackets?

Teddyfles(Posted 2004) [#1]
Hi,
I wouldn't really call myself a beginner, but I do feel this might be somewhat of a beginner-question.

Anyway...
What I'd like to do is always use brackets in Blitz, even though "officially" some commands don't require them. Example: according to the docs you have ReadFile(filename$) and DeleteFile filename$.
I don't know why one command uses brackets and the other doesn't, but luckily the commands without brackets also work with them: DeleteFile(filename$).

However, I found something weird.

If x Then Color(0, 0, 0) Else Color(255, 255, 255)
This doesn't work and I get an Expecting ')' error.

However, the following variations all DO work:
If x Then Color(0, 0, 0)

If x Then
  Color(0, 0, 0)
Else
  Color(255, 255, 255)
EndIf

If x Then: Color(0, 0, 0): Else: Color(255, 255, 255): EndIf

If x Then Color 0, 0, 0 Else Color 255, 255, 255


So my question is: what's the deal with brackets in Blitz? When should I use them and why can't I simply use them for every command?

Sorry if it's been discussed before, I couldn't find the awnser using the search function.


Perturbatio(Posted 2004) [#2]
I may be wrong, but this looks like a bug.


Jeppe Nielsen(Posted 2004) [#3]
As rule just use brackets on commands that return values, and don't on those who doesn't.


Rimmsy(Posted 2004) [#4]
Yeah, this is a bug. It's been here a lllllllloooong time. You'll just have to do as you stated, and move things to different lines.


Diablo(Posted 2004) [#5]
Quote:If x Then Color(0, 0, 0) Else Color(255, 255, 255)

try putting a ':' after the 'If x Then Color(0, 0, 0)'

it always works in my code like that:
If x Then Color(0, 0, 0): Else Color(255, 255, 255)

have fun :)


Teddyfles(Posted 2004) [#6]
Ok, well I think that from now on I'll just use brackets as often as possible. It just looks nicer to me and when Blitz has a problem with it, it'll let me know.

Stefanous, that's weird. I thought that a ':' basicly was the same as an enter in Blitz.
If x Then PoopYourPants(): Else KeepItClean()

That works but this doesn't:
If x Then PoopYourPants()
Else KeepItClean()

There it needs an EndIf. Hmmm, Blitz is full of surprises.


big10p(Posted 2004) [#7]
What Jeppe said. I always use brackets when calling my own functions, though.


Curtastic(Posted 2004) [#8]
you also cant use brackets on type operators like New, After, Last, even though they return a value