Return Error.
BlitzMax Forums/BlitzMax Programming/Return Error.
| ||
Main file.Import xorsteam.xors3d ' Nucleo del motor Xors3D. ' - Includes Objetos. Include "Tipos/TGraficos3D.bmx" G3D:TGraficos3D = TGraficos3D.Init() For Local oG3D:TGraficos3D = EachIn G3D.listaG3D:TList Print oG3D.anchoPantalla:Int Next xDeInit() File Include. Local G3D:TGraficos3D = Null Type TGraficos3D Field nombreAPP:String = "ISON BASE" Field anchoPantalla:Int = 800 Field altoPantalla: Int = 600 Field profundidadColor:Byte = 32 Field estiloPantalla:Byte = 0 Field sincVertical:Byte = True Field listaG3D:TList = Null ' Constructor Objeto. Function Init:TGraficos3D( anchoPantalla:Int = 800, altoPantalla:Int = 600, profundidadColor:Byte = 32, estiloPantalla:Byte = 0, sincVertical:Byte = True ) Local oGraficos3D:TGraficos3D = New TGraficos3D If Not listaG3D:TList Then listaG3D:TList = New TList End If listaG3D.AddLast( oGraficos3D:TGraficos3D ) oGraficos3D.anchoPantalla:Int = anchoPantalla:Int oGraficos3D.altoPantalla:Int = altoPantalla:Int oGraficos3D.profundidadColor:Byte = profundidadColor:Byte oGraficos3D.estiloPantalla:Byte = estiloPantalla:Byte ograficos3D.sincVertical:Byte = sincVertical:Byte oGraficos3D.Config() Return oGraficos3D:TGraficos3D End Function Method Config:Int() Try If ( xGfxModeExists ( Self.anchoPantalla:Int, Self.altoPantalla:Int, Self.profundidadColor:Byte ) ) Then xAppTitle Self.nombreAPP:String XGraphics3D ( Self.anchoPantalla:Int, Self.altoPantalla:Int, Self.profundidadColor:Byte, Self.estiloPantalla:Byte, Self.sincVertical:Byte ) Else Throw "Modo G3D no compatible" End If Catch e$ Notify e$ End Try End Method End Type Error Return: Unhandled Exception: Attempt to acces field or method of null objetc. help. |
| ||
Unhandled Exception: Attempt to acces field or method of null objetc. On which line? (the IDE should highlight the line the error occurred on) |
| ||
. |
| ||
There are a couple of things causing the issue This is creating a new variable at this point in the code which the compiler allows but is NOT a part of the oGraficos3D object If Not listaG3D:TList Then change it to If Not listaG3D Then You will then see the real error which is listaG3D.AddLast( oGraficos3D:TGraficos3D ) which should be corrected to If Not oGraficos3D.listaG3D Then oGraficos3D.listaG3D = New TList End If and also oGraficos3D.listaG3D.AddLast( oGraficos3D:TGraficos3D ) As a general rule of thumb always use 'Strict' or maybe 'SuperStrict' to help catch errors and only define the type of a variable where you are declaring it. Don't use things such as 'If Not listaG3D:TList Then'. If you use 'Strict' or 'SuperStrict' and not use things as 'If Not listaG3D:TList' then you will get an error at that exact line telling you that listaG3D is unknown ( in NG it will tell you that 'listaG3D cannot be accessed from here' or something similar - you will then think that listaG3D is part of oGraficos3D object ;-) There are other things to question in your code but one thing at a time is best to understand. |
| ||
OK, thanks You :) |