02-11-2005, 12:03 AM
I am trying to get freebasic to do a bit of oop by defining some variables in a typeset as functions. However, I do not know how to give these functions access to the other variables in my datatype.. Here's the functionless code..
while it's not hooked up, what I want to do is call setName, and assign the incoming value to the 'name' variable of the myOBJ datatype. Is this possible to do? Below is an example of how you would do it in java.
Thanks!
Code:
type myOBJ
setName as sub(xName as string)
getName as function() as string
name as string
end type
dim foo as myOBJ
declare sub setName(xName as string)
declare function getName() as string
'init
foo.setName = @setName
foo.getName = @getName
sub setName(xName as string)
end sub
function getName() as string
getName = "hello"
end function
while it's not hooked up, what I want to do is call setName, and assign the incoming value to the 'name' variable of the myOBJ datatype. Is this possible to do? Below is an example of how you would do it in java.
Code:
class Foo
String name;
Foo() {
}
public void setName( String arg0) {
this.name = new String();
this.name = arg0;
}
Thanks!