Error Codes?

Blitz3D Forums/Blitz3D Programming/Error Codes?

Is there a list of Blitz3D error codes anywhere?
When I receive an error message, it's usually rather cryptic and there is nothing in the help file. Sometimes the forums help but more often than not, they don't.

The usual one is memory access violation. Meaning you trying to access something that doesn't exist.

You used the wrong file path for a media item is the main cause :)

But as to your question, i don't know of such a thing :)

Hu? I found the error messages rather descriptive. Make sure to turn on debugging mode, otherwise you will always get "memory access violation". In some rare cases you'll get that message even in debugging mode, but usually the message is pretty clear. Things like "Entity does not exist" signals oftenly that a mesh couldn't be loaded because you mistyped the filename or something.

Sometimes Debugging is a bit hard. Fo rthis case you need to search for the error by exclusion: One by one deactivate parts using goto and labels to skip things, until you find the part that didn't work.

I also suggest to use an other Editor than the one that comes with Blitz because since some time the Debugger Support (jumping to the line of the error) is no longer as good as in the beginning. And AFAIK the third party IDEs have better Debugging support. Someone correct me if I'm wrong.

Specifically, the error I was seeking was "Expecting identifier". After a bit of trial and error, I found the cause.

When programming in C++, it is often desirable to include the "const" keyword before certain variables in function definitions. This tells the compiler that this particular variable will not be changed inside the function (and aids in debugging). I assumed B3D had similar functionality, since it also has the Const keyword; but it does not. Const (I assume) can only be used when specifying global variables, not function parameters.

When programming in C++, it is often desirable to include the "const" keyword before certain variables in function definitions. This tells the compiler that this particular variable will not be changed inside the function


I haven't done any c programming in about 12 years, but that's not my recollection of what c compilers do. My understanding is that c treat constants entirely separate from variables, as Blitz does. The values are inserted "hard-coded" at compile time.

Why define function parameters as constant? If they're constant, they don't need to be parameters at all. You can specify a default value for a function parameter like this :

Function AddTwoNumbers(a=1,b=2)
   Return a+b
End Function


Will return 3 unless you specify either a, b or both.

[ This is starting to get off-topic but I'll give an answer. ]

There are basically 2 ways of using constants in C++.

1) As a local or global variable, the same way B3D uses the keyword; this allows you to use a variable name instead of its value. If you need to change the value of the variable, you can do so in one place rather than having to find and replace the value throughout your code.

2) The second is to specify function parameters that are not meant to change inside the function.

Say you have the following C++ function (using your example):

int AddTwoNumbers(const int a = 1, const int b = 2) {
	return a + b;
}


Without the const keyword in the parameter definition, it would be possible to change a variable inside the function. Sometimes you want to do this -- in which case you would not use the const keyword -- but if you are certain the value won't (or shouldn't) change, using the const keyword will generate a compiler error if the variable is changed anywhere inside the function.

In the above example, neither parameter is being changed inside the function. However, if you wanted to do something like this...

	a = Math.Abs(a);


...to ensure "a" is always positive before adding it to "b", the compiler would generate an error if you used the const keyword in the parameter definition.

In short, all of this is simply to help debugging. I'd be happy to answer other C++ questions (if I know the answer) but you may want to investigate C++ on other websites if you're interested.

Not really. I have no interest in going back to C++. I was trying to show you how to do what you wanted to do in Blitz, but I guess I didn't.

The reason I created this post was because I thought B3D allowed defining function parameters the same way C++ does. It doesn't. That's why I was getting the "Expecting identifier" error. I wanted a list of error codes to see if they could provide me with any insight into such a cryptic error message. It was only after I removed the Const keyword from my function parameters did the errors go away. But if a list of error codes were available, I would not have had to resort to the trial-and-error method and could know exactly why the error was cropping up in the first place.

That's all.