I just don't know how to express in english what I'm trying to do. Basicly I was trying to use the name of the text box as the declaring name for the new text box so as such it would not conflic with eachother if I declared more then one... like going like this:
cTextfield(..., name here)
cTextfield(..., name here)
...
I'd think if both of their objects had the same name, then it would work.
Because I'm trying to make an object of the textbox within the function so the function can be re-used. That is why I did the thing above. But that would not work since it's a strign stored in a variable and cannot convert that string to make itself a variable...
if that makes any sense at all...
EDITED
sorry for the late responce... real life -> time consuming ;D
EDITED
I've just re-writen my code. Made it into an object type thingy instead of a fonction, but it takes way too many lines to give it all the info it needs, I'd like it to be only one line like a function.
But I was told not to put new objects in loops.. for I dunno what but I think it'd affect memory.
How would you make this type into a function using the type so I can only type in one line in the loop and also re-use that function?
Graphics 800,600,0
'-------------------------
' VARIABLES
Global gExit:Int = False
'-------------------------
' TYPES
Type cTextfield
Field x:Int,y:Int
Field width:Int,height:Int=15
Field ftext:String
Field selected:Int
Method Update()
If(MouseX()>x)And(MouseX()<(x+width))And(MouseY()>y)And(MouseY()<(y+height))
SetColor(130,200,240)
Else
SetColor(0,170,255)
EndIf
DrawLine( x, y, x+width, y) ' top
DrawLine( x, y+height, x+width, y+height) ' bottom
DrawLine( x, y, x, y+height) ' left
DrawLine( x+width, y, x+width, y+height) ' right
DrawText( ftext, x+2, y+1 )
End Method
End Type
test:cTextfield = New cTextfield
'-------------------------
' LOOP
While Not gExit = True
Cls
test.x=100
test.y=100
test.width=100
test.ftext="What?"
test.Update()
'-------------------------
' Close Game
If KeyHit(KEY_ESCAPE) Or AppTerminate() Then
gExit = True
EndIf
'-------------------------
Flip
Wend
End
oh ya ive been reading some of the tuts in the tuts section and i find them to be very enlightning :D
EDITED
I guess the closest thing if not the thing, to what i wanted to do would be:
Function cTextfield( x%, y%, width%, height%, var name:tTxtBox)
name=New tTxtBox
name.x=x
name.y=y
End Function
from dreamora..