Example of IN super for procedure and function

GaneshP

New Member
Hi,
cane any one give me example of IN SUPER for internal procedures and functions, how to use
 

Cringer

ProgressTalk.com Moderator
Staff member
What have you researched so far?
 

GaneshP

New Member
inproc internal procedure is there in main.p and sub.p programs, after added sub.p as a super-procedure in main.p.
in this case how to use IN SUPER Keyword ? please explain ?

/* main.p */
define var hdl as handle.
run sub.p persistent set hdl.
this-procedure:add-super-procedure(hdl).

run inproc.

procedure inproc:
message "Main.p inproc".
run super.
end.



/* sub.p */

procedure inproc:
message "Sub.p inproc".
end.
 

Osborne

Active Member
IN SUPER is used to declare that the function is found in a super procedure and that the function is implemented in the super procedure.
Code:
/* main.p  */
 define var hdl as handle.

FUNCTION TodaysDate RETURNS DATE () IN SUPER.

 run sub.p persistent set hdl.
 this-procedure:add-super-procedure(hdl).

MESSAGE "The date is" TodaysDate() VIEW-AS ALERT-BOX.

/* sub.p */
procedure inproc:
   message "Sub.p inproc" VIEW-AS ALERT-BOX.
end.

FUNCTION TodaysDate RETURNS DATE ().
    RETURN TODAY.
END FUNCTION.
It is not used for internal procedures and for these look at this example:
Code:
/* p-podrvr.p */
FUNCTION SetPartName RETURNS INTEGER (INPUT a AS CHARACTER) FORWARD.
     
DEFINE VARIABLE h AS HANDLE.
DEFINE VARIABLE localPartName AS CHARACTER.

/* Add a super procedure */
RUN p-posupr.p PERSISTENT SET h.
THIS-PROCEDURE:ADD-SUPER-PROCEDURE (h).
SetPartName("2000 Calendar").

PROCEDURE sample1:
    DEFINE INPUT-OUTPUT PARAMETER a AS CHARACTER.
    a = a + "proc: Part name is: ".

   /* Invoke procedure sample1 in the super procedure. */
    RUN SUPER (INPUT-OUTPUT a).
END PROCEDURE.

FUNCTION sample2 RETURNS CHARACTER (INPUT-OUTPUT a AS CHARACTER).
    a = a + "func: Part name is: ".

   /* Invoke function sample2 in the super procedure. */
    SUPER (INPUT-OUTPUT a).
    RETURN a.
END FUNCTION.

FUNCTION GetPartName RETURNS CHARACTER ():
    RETURN localPartName.
END FUNCTION.

FUNCTION SetPartName RETURNS INTEGER (INPUT partname AS CHARACTER):
   localPartName = partname.
END FUNCTION.

/* p-posupr.p */
/* Defines a new version of the internal procedure sample1 and a new version of the user-defined function sample2 
DEFINE VARIABLE h AS HANDLE.

FUNCTION GetPartName RETURNS CHARACTER () IN H.

PROCEDURE sample1:
    DEFINE INPUT-OUTPUT PARAMETER a AS CHARACTER.
   
   h = TARGET-PROCEDURE.
    a = a + GetPartName().
    MESSAGE "TARGET-PROCEDURE is:" TARGET-PROCEDURE:FILE-NAME VIEW-AS ALERT-BOX.
   MESSAGE "SOURCE-PROCEDURE is:" SOURCE-PROCEDURE:FILE-NAME
   VIEW-AS ALERT-BOX.
END PROCEDURE.

FUNCTION SAMPLE2 RETURNS CHARACTER (INPUT-OUTPUT a AS CHARACTER):
   h = TARGET-PROCEDURE.
   a = a + GetPartName().
   RETURN a.
END.
 
Top