Error Codes?

Blitz3D Forums/Blitz3D Programming/Error Codes?

Omnigalactic(Posted 2004) [#1]
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.


Ross C(Posted 2004) [#2]
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 :)


jfk EO-11110(Posted 2004) [#3]
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.


Omnigalactic(Posted 2004) [#4]
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.


Gabriel(Posted 2004) [#5]
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.


Omnigalactic(Posted 2004) [#6]
[ 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.


Gabriel(Posted 2004) [#7]
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.


Omnigalactic(Posted 2004) [#8]
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.


Soselo(Posted 2012) [#9]
I am still receiving the "Expecting Identifier" error message after many attempts of rewriting my parameters. It brings my cursor to the GoTo command at the beginning of my program. Any help would be much appreciated. I am still a beginner, testing out some starter codes so any explanations or pointers are a major help.


_PJ_(Posted 2012) [#10]
Gabroiel, I think you misunderstand how it works.
The constant parameters in C++ are especially useful for pointer values which are not universally constant, but when they are passed to a function, you want to be sure that they cannot be changed by that function even though they are not specifically decalred with a value with the decalaration of the funciton, or that multiple uses of the function might use the same parameter having the same value.

Omnigalactic, correct - there is only one use for Const which is an initial declaration of a variable type that never ever changes value. This must be declared outside of functions.

Typically, "Expecting Identifier" occurs when the following commands are used without declaring values, expressions or arguments for them:

Read
Type (or Field)
Global
Const
Dim
For
GoTo
GoSub

It may be that these commands have been incorrectly used, for example, concerning your GoTo line, does the label following GoTo actual;ly exist as ".LabelName" in your program?


Rroff(Posted 2012) [#11]
Obligatory you shouldn't be using GoTo comment :P (unless your using fastpointer for threads/function pointers).

Last edited 2012


GfK(Posted 2012) [#12]
I am still receiving the "Expecting Identifier" error message after many attempts of rewriting my parameters. It brings my cursor to the GoTo command at the beginning of my program. Any help would be much appreciated. I am still a beginner, testing out some starter codes so any explanations or pointers are a major help.

Thread necrophilea at its absolute worst...

As I told you in the other thread (the one you started, as opposed to this one, which was started eight years ago and has nothing to do with your problem) - you need to post some code so everybody can see what you are doing wrong.

(But do that in the other thread - not this one).