Can you do things like:
Function DoSomething(SomeObject.SomeType = Null)
I'm assuming not as I can't get it to work.
Its not possible with blitz.
Null is not a constant value, so no,it's impossible.
Not possible.
Type myType
Field blah
End Type
Function myFunction(myInstance.myType = Null)
Return myInstance\blah
End Function
returns an error.
You'd think a fellow who's done more with Blitz3D in the last year than most people have ever done would know something like that, eh? >:D
[EDIT] ROFL: nice edit Noel. Undoubtedly revisionist history accounts for some of that expertise of yours eh? XD[/EDIT]
yeah, even I knew that.
but then again maybe im just lying!! :)
It's interesting considering it didn't work for me in the past. I shall have to try this again.
I suppose you could use the handle and object method. Probably not like this, but it's just an example.
Type myType
Field blah
End Type
Instance.mytype = myfunction(10)
Print Instance\blah
myfunction(20,Handle(Instance))
Print Instance\blah
WaitKey()
Function myFunction.mytype(value,typehandle=0)
Local thisinstance.mytype = Object.mytype(typehandle)
If thisinstance<>Null
thisinstance\blah = value
Else
thisinstance = New mytype
thisinstance\blah = value
EndIf
Return thisinstance
End Function
Someone once tried to explain to me why this is impossible, but I didn't understand what they were trying to say. It seems trivial to me.
Yeah, I find it a bit of a strange omission - I'm sure there must be a good reason.
Never mind, I'll just have to get used to passing in "Null"s instead :-)
Function DoSomething(SomeObject.SomeType = Null)
Well this is possible like DJWoodGate said. You can't write it that way, but you can have the same "functionality". But I might have gotten you wrong, Test this sample.
[code]
Function DrawEntry(Pointer%=0)
Local P.SomeType = Object.SomeType Pointer
If P <> Null;Did they send a long an object or just a ZERO?
;Good
Text P\x,P\y,"- Object Verified -"
Else
Text 0,Rand(100),"- Object NOT Verified - or none Found"
End If
End Function
Type SomeType
Field X,Y
End Type
P.SomeType = New SomeType
P\X = 21:P\Y = 50
P2.SomeType = New SomeType
P2\X = 75:P2\Y = 20
DrawEntry(Handle P)
DrawEntry(Handle P2)
DrawEntry(0)
WaitKey()
[code/]