PDA

View Full Version : With {As|Like} vartype At- a virtual idea



ReneMiner
30-01-2015, 19:57
Uses "console"


Type t_Test
X As Long
Y As Long
Z As Long
magic As Function

End Type

Function t_Test.magic() As Long
Function = Pow(Me.x+Me.y,Me.z)+(Me.z+Me.y*Me.x)*Me.z*(Me.y -Me.x)
End Function

DWord pData = HEAP_Alloc(SizeOf(t_Test))

With As t_Test At pData
.X = 1
.Y = 2
.Z = 3
PrintL .magic
End With


PrintL $CRLF & " --- any key to end ---"
WaitKey


sorry i wish it would run

the idea is to use With As ... [At ...] so might need steps for understanding to reach the syntax above:



'just use "With" and instant layover in one go:

With [Local win] As cWindow At Dialog_GetUser(CBHNDL,1)


.SetText("I'm a new caption at the current calling window")
.Refresh() ' *** redraw is keyword already
' :( why cant this be differentiated...
End With




now got the idea? Great were if this were possible too:



With Like "cWindow" At Dialog_GetUser(CBHNDL,1)


it should be possible to use more than 1 "With As ... At ..." inside a function and allow usage of different types in different executions of the same function when "With Like ... At ..."

:!: perhaps in general the At is not even mandatory
- we could create a "real local variable" of some udt also this way and instantly use its properties & functions - until End With follows
(in case we need to name the variable somehow then it could stay valid until exit funcion)