• Description:
    REPROC keyword is an equivalent of RETURN keyword. REPROC allows You to execute a part of code, before the procedure will be leaved.
    This feature allows single or multiple DREPROC definition. When single only used, no OF <id> allowed, because there is not defined another code. When REPROC keyword reached it will setup return values and launch the DREPROC code.

    This is beta feature and may not be safe.

  • Syntax:
      REPROC <list> [ OF <id> ]
    

    where list is <list> of return values to be returned by proc and <id> is DREPROC identificator, which selects DREPROC code to be executed before the procedure leaves.
      DREPROC [ <id> ]
    

    where <id> is the DREPROC identificator.

  • Example:
    Imagine: Your procedure does some operations and it uses some RETURNs to leave a procedure earlier. Some times is enough to only return a values, but sometimes a man need to do some operations, before the procedure will be leaved:
      PROC AllocScene()
        DEF scene:PTR TO LONG,err,n
        IF (scene:=AllocMem(4*SIZEOF_LONG,MEMF_PUBLIC|MEMF_CLEAR))=NIL THEN RETURN NIL,ERR_Mem
        LOOP n:=3
          IF (scene[n],err:=AllocObject())=NIL THEN REPROC NIL,err
        ENDLOOP
      DREPROC
        LOOP n:=3
          IF scene[n] THEN FreeObject(scene[n])
        ENDLOOP
      ENDPROC scene,ERR_None
    

    This procedure will allocate a block of memory for scene and fill this scene with four objects. If scene allocation will fail, procedure will return NIL and ERR_Mem. If an object allocation will fail, then comes DREPROC code to be executed, so all object will be freed, and NIL and err (returned by AllocObject()) will be returned. I know this may be used in same way as EXCEPTions, but this allows more then one code blocks, see above.