Types confuse me in MAX
BlitzMax Forums/BlitzMax Beginners Area/Types confuse me in MAX
| ||
Can someone tell me why I get Identifyer "udate" not found in this??Global g_radio = LoadAnimImage("gfx\gui\radio.bmp",8,8,0,2,MASKEDIMAGE) 'Graphics for the radio. Type radio Const s_radio = 1 'Tells the state field that the radio is selected Const u_radio = 0 'Tells the stste field that the radio is unselected Global rlst:TList 'List (sure you knew that) Global t_radio 'This counts the total # of radios being used. Field id 'This is the ID or # of the return in the function Field state 'Current state of the button Field x,y 'x,y location of the radio button Function Create(x,y) 'Create function making the button. If rlst = Null Then rlst = CreateList() r:radio = New radio ListAddLast(rlst,r) id = t_radio + 1 state = u_radio x = x y = y Return id End Function Method Update() 'Method for drawing the radio button DrawImage g_radio,x,y,state End Method End Type Function CreateGUI() radio.Create(x,y) End Function r.update() |
| ||
Simply put, there is no definition for r globally Here (since I wasn't exactly sure what all the field were for and what not, I optimized it a bit based on your general code): Global R:Radio Type Radio Const S_Radio:int=1 Const U_Radio:int=0 Global RLST:TList Global T_Radio:int Global G_Radio:TImage Field ID:Int Field State:Int Field X:int,Y:Int Method Update() If G_Radio <> null then DrawImage(g_radio,x,y,state) End Method Function Create:Radio(X1:int,Y1:int) Local R:Radio if RLST = null then RLST = createlist() R = New Radio State = U_Radio ID = T_Radio+1 X=X1 Y=Y1 Return R End Function End Type Function CreateGUI() R = Radio.Create(5,5) End Function R.Update() |
| ||
Im not sure what you have above now, but I added comments to the code in the top of this post |
| ||
Alright, well here is why update returns an error. The object 'r' in your "r.Update()" isn't defined anywhere. Sure you have r:radio in the function create which is assosiated with the type radio (mind you, since you haven't defined R as global to the program, this is merely local to the function create of the type radio), however 'r' from 'r.update()' hasn't been defined as a radio object (globally). AT the top of your code (Very top), put in this "Global R:Radio" See if that helps. |
| ||
yep that fixed it thanks |
| ||
Sorry I figured it out... |