Forum

> > Off Topic > Method in BlitzMax
ForenübersichtOff Topic-ÜbersichtEinloggen, um zu antworten

Englisch Method in BlitzMax

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Method in BlitzMax

Avo
User Off Offline

Zitieren
Hi, I'm getting started with BlitzMax and I met a problem which appears when below fragment of code is compiled (to be precise - the last line at screenshot; "Mis.Fired"):
IMG:https://s7.postimg.org/l5dn7qfm3/blitzproblem.png

Error: Unhandled Exception: Attempt to access field or method of Null object.

I'm not an expert, but I think that bm just tries to access field "Mis" in type TPlayer what obviously wasn't my point. I can simply get rid of this problem if I want to access variable that isn't declared in that type, I can use "global" key-word and everything works fine. But I'm not able to find solution for locals. I could use a function instead of a method, but I hope it's also possible with methods (it's quite shorter). Is anyone here who could help me?

Spoiler >

alt Re: Method in BlitzMax

Starkkz
Moderator Off Offline

Zitieren
You must make sure that none of the objects in these indexes is null, otherwise you won't be able to access an object that does not exist.

Also, you can't access to the 100th object when you're using your array, it's actually the limit. You can access from 0 to 99.

alt Re: Method in BlitzMax

Avo
User Off Offline

Zitieren
Thank you very much. It works without any compiler's error. I've forgotten that arrays in BM begins at 0, not at 1.

alt Re: Method in BlitzMax

Apache uwu
User Off Offline

Zitieren
user Avo hat geschrieben
Thank you very much. It works without any compiler's error. I've forgotten that arrays in BM begins at 0, not at 1.


Caveats with being a Lua scripter
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antwortenOff Topic-ÜbersichtForenübersicht