As far as I can tell there is still no support for returning a user defined type from a function. Does anyone have an effective workaround for this issue?
If you aren't sure what I'm talking about, I wrote up a quick snippet explaining it.
// This project shows the problem with the DBPro language. A UDT is created,
// defined, and then passed to a function. That function is unable to return
// the UDT and instead returns an int variable. This makes the
// task the program is attempting to complete, creating a window drawing
// function that could be used for an undetermined number of windows,
// seemingly impossible.
type windowproperties
x
y
w
h
border
title
title$
hovering
endtype
mywindow as windowproperties
window(mywindow):sync
mywindow.x=50:mywindow.y=50:mywindow.w=400:mywindow.h=175:mywindow.border=2:mywindow.title=1:mywindow.title$="Test Window":mywindow.hovering=0
sync on
do
cls
//This line crashes on compile, mywindow on the left side of the equation is not recognized as the UDT it was defined as.
`mywindow=window(mywindow)
//To test what value is being returned by the function we can print it.
print window(mywindow)
//Compiling and running the program suggests that the first defined value, active.x, is returned. This is 12.5% of the data
//we were expecting.
ink rgb(255,255,255),0
print screen fps()
print mywindow.x
print mywindow.y
sync
LOOP
function window(active as windowproperties)
ink rgb(180,180,180),0:box active.x,active.y,active.x+active.w,active.y+active.h
if active.border>0 then ink rgb(255,255,255),0:box active.x+active.border,active.y+active.border,active.x+active.w-active.border,active.y+active.h-active.border
if active.title=1 then if mousex()>active.x+active.border then if mousex()<active.x+active.w-active.border then if mousey()>active.y+active.border then if mousey()<active.y+active.border+22 then hovering=1
if active.title=1
if active.hovering=1 then ink rgb(0,0,200),0:box active.x+active.border,active.y+active.border,active.x+active.w-active.border,active.y+active.border+22
if active.hovering=0 then ink rgb(200,200,200),0:box active.x+active.border,active.y+active.border,active.x+active.w-active.border,active.y+active.border+22
ink rgb(255,255,255),0:center text (active.x+active.w)/2,active.y+active.border+2,active.title$
endif
if mouseclick()=1 then if active.hovering=1
dispx=mousex()-active.x:dispy=mousey()-active.y
sync
active.x=mousex()-dispx:active.y=mousey()-dispy
endif
ENDFUNCTION active //While this does not generate an error, the data is not being correctly passed.
My site, for various stuff that I make.