Return Name ?
BlitzMax Forums/BlitzMax Beginners Area/Return Name ?
| ||
function bitamp(name) name=createbitamp return name end function bitmap(a) 'which is like a=bitmap but in the brackets hidebitamp(a) ' then you call the name of the object how do i do this ? |
| ||
Assuming createBitmap returns a Bitmap object:Function bitmap:Bitmap() return createbitmap() End Function Local a:Bitmap = bitmap() ' This is not like bitmap(a) at allHowever your 'bitmap' function seems to be redundant, why not just call createBitmap from the start? |
| ||
Yeah, you probably have to do a=bitmap(n), and of course if a isn't defined you may need Local a:whatever= or Global etc. Otherwise, with bitmap(a) you would be passing the value stored in variable a (which if undefined will be 0), to the function, and are reading back from the function nothing because you don't make the function equal anything. To store the return value you have to do something=function(n). You could also optionally use VarPtr to pass the pointer to the variable `a` so that you can directly modify it in the function. ie. Function bitmap(nameptr:Int Ptr) nameptr[0]=createbitmap() End Function Local a:Int=0 bitmap(VarPtr(a)) hidebitmap(VarPtr(a)) or something like that, although Mikkel's version is easier to do. |
| ||
This really helps me out Thank you guys |