Compile error setting a persistent procedure handle to a cla

Posted by Blake Stanford on 29-Jan-2020 20:02

All,

According to the documentation, running a procedure persistent and setting the handle to a class property is legal.

PERSISTENT [SET proc-handle]
Specifies that the external procedure be instantiated and run as a persistent procedure.
You can return the handle to the persistent procedure in proc-handle specified as a field, variable, class property, or output parameter defined with the HANDLE data type. If you do not specify proc-handle, you can find the procedure handle for this procedure using the FIRST-PROCEDURE or LAST-PROCEDURE attributes of the SESSION system handle.
 

  class Foo:

    define public static property hProc as handle.

  end class.

  test.p

    run myproc.p persistent set Foo:hProc.

  end test.p

A compile error is thrown when compiling test.p 

  **Unknown Field or Variable name - Foo. (201)

Am I misunderstanding the documentation or is the documentation wrong or is it a bug?


This is on OpenEdge 11.7.5

All Replies

Posted by Peter Judge on 29-Jan-2020 20:18

It's a bug, or at least an incomplete feature.
 
It's the member-of-object part. You have to assign to an intermediary variable first. Something like
 
    Def var h as handle.
    Run set h.
    Foo:hProc = h.
 
 
 

Posted by Blake Stanford on 29-Jan-2020 20:30

Thanks Peter, that is not the answer I was looking for.  We are replacing Global Shared Variables and the thought is a static class with public properties or variables equivalent to the GSVs.  

Posted by ChUIMonster on 29-Jan-2020 20:35
Posted by Blake Stanford on 29-Jan-2020 21:17

Thanks Tom,

What you describe is essentially what I'm attempting.   The issues appears that one cannot use a class property as the persistent procedure handle with the SET syntax option.  So a simple replace the GSVs with an equivalent class property is not going to be possible.  It looks like more complex refactoring is going to be needed.

Also appears that a class property/variable cannot be used as an output parameter for a run procedure statement.

run test.p (output foo.hProc) gives a syntax error: Cannot use object reference qualified variable name as an INPUT-OUTPUT or OUTPUT parameter. (13458)

This thread is closed