Friday, July 17, 2015

Anonymous tables and fields in Dex, and a function pointer / delegate idea

Just generalized a function by using an anonymous table + anonymous field. I didn't know anonymous fields could be used in this manner

Generialized partial transfer function
function Transfer()
inout anonymous table xferTable;
inout anonymous field qtyField;

'QTY to Invoice' of table SOP_LINE_WORK = qtyField of table xferTable;

Callers
Caller 1 - Transfer(table TransferTable1, QTYTo of table TransferTable1)
Caller 2 - Transfer(table TransferTable2, 'Actual QTY' of table TransferTable2)

Function pointers / delegates
This is not directly supported by the Dex language. However, it just occurred to me that I could create a "delegate invoker" in Dex by using the dynamic script execute() function. Here's some psuedocode for this idea:
function Exec(string functionName)
execute(functionName);

Caller - Exec("doStuff")

And for parameters, return values you could use anonymous fields. 
function Execute(string functionName, anonymous field param1)
execute(functionName, param1)

No comments:

Post a Comment

There was an error in this gadget