gnozals solution has one little weakness:
the return-struct is static, so it will stay inside the procedure.
he is just assigning a structured pointer to it.
if the proc is called twice, the old value will be overwritten.
Code: Select all
Structure Testing
d.l
e.l
f.l
EndStructure
Procedure.l Testing(a, b, c)
Static TestingResult.Testing
TestingResult\d = a * 5
TestingResult\e = b + 100
TestingResult\f = c / 4
ProcedureReturn @TestingResult
EndProcedure
*TestingResult1.Testing = Testing(1, 2, 3)
Debug *TestingResult1\d
Debug *TestingResult1\e
Debug *TestingResult1\f
*TestingResult2.Testing = Testing(4, 5, 6)
Debug "---"
Debug *TestingResult2\d
Debug *TestingResult2\e
Debug *TestingResult2\f
Debug "---"
Debug *TestingResult1\d
Debug *TestingResult1\e
Debug *TestingResult1\f
for WinAPI calls that need a structured return,
you create your structured variable before the call and pass it's pointer to the routine.
you can chose the same approach for your own procedures.
Code: Select all
Structure Testing
d.l
e.l
f.l
EndStructure
Procedure.l Testing(a, b, c, *T.Testing)
*T\d = a * 5
*T\e = b + 100
*T\f = c / 4
ProcedureReturn #True
EndProcedure
TestingResult1.Testing
Testing(1, 2, 3, @TestingResult1)
Debug TestingResult1\d
Debug TestingResult1\e
Debug TestingResult1\f
Debug "---"
TestingResult2.Testing
Testing(4, 5, 6, @TestingResult2)
Debug TestingResult2\d
Debug TestingResult2\e
Debug TestingResult2\f
Debug "---"
Debug TestingResult1\d
Debug TestingResult1\e
Debug TestingResult1\f
oh... and have a nice day.