GregTomkins
Active Member
10.2B
Any bright ideas for how to best handle a dynamic call with output parameters?
The code below works, but only due to the hard-coded single CHAR output. I was hoping for some solution that would support arbitrary numbers of arbitrary types in some cleanish way.
I was hoping I could do something along the lines of SET-PARAMETER (... h_out_fld), eg. a field handle, but that doesn't seem to work; it creates ye olde 'Incompatible datatypes found during runtime conversion. (5729)' due to passing a field handle.
EDIT: I suppose I would need to CREATE or FIND a record into h_out_buf as well, but I am not getting that far anyway.
Any bright ideas for how to best handle a dynamic call with output parameters?
The code below works, but only due to the hard-coded single CHAR output. I was hoping for some solution that would support arbitrary numbers of arbitrary types in some cleanish way.
I was hoping I could do something along the lines of SET-PARAMETER (... h_out_fld), eg. a field handle, but that doesn't seem to work; it creates ye olde 'Incompatible datatypes found during runtime conversion. (5729)' due to passing a field handle.
EDIT: I suppose I would need to CREATE or FIND a record into h_out_buf as well, but I am not getting that far anyway.
Code:
DEF VAR h AS HANDLE NO-UNDO.
DEF VAR h_out AS C NO-UNDO.
DEF VAR h_out_tbl AS HANDLE NO-UNDO.
DEF VAR h_out_buf AS HANDLE NO-UNDO.
DEF VAR h_out_fld AS HANDLE NO-UNDO.
CREATE TEMP-TABLE h_out_tbl.
h_out_tbl:ADD-NEW-FIELD("out","CHARACTER").
h_out_tbl:TEMP-TABLE-PREPARE("out").
h_out_buf = h_out_tbl:DEFAULT-BUFFER-HANDLE.
h_out_fld = h_out_buf:BUFFER-FIELD("out").
CREATE CALL h.
ASSIGN
h:CALL-NAME = "greg/foo.p"
h:NUM-PARAMETERS = 1.
h:SET-PARAMETER (1, "CHARACTER", "OUTPUT", h_out).
h:INVOKE().
MESSAGE h_out.