Here is my version:

FUNCTION GET.CALLING.STACK(SPECIFIC,F2)
*-----------------------------
* UCONV.BP GET.CALLING.STACK
* RETURNS PROGRAM AND ALL CALLERS (CALLING STACK)
* ED BURWELL
* 4/1/2005
*-----------------------------
* PARAMETERS:
*  SPECIFIC - specific item you want from stack
*           - {null} = Return entire stack
*           - M      = 'M'yself: just return the 1st item in the stack
*           - C      = 'C'aller: just return the calling program
*           - I      = 'I'nitiator: the program that initiated this stack
*           -
*  F2       - FUTURE USE
*
* RETURNED TO CALLER:
*  STACK    - FILE NAME AND PGM NAMES OF CALLING STACK
*           - THE CURRENT PROGRAM IS ON TOP
*-----------------------------
    STACK=""
    THIS.PGM = "GET.CALLING.STACK"
   *---- ----*
    S49=SYSTEM(49) ; * CALLING STACK
    MAX=DCOUNT(S49,@AM)
   *---- STRIP OFF NULLS ----*
    FOR I=MAX TO 1 STEP -1
       THING=TRIM(S49<I>)
       IF LEN(THING)=0 THEN S49=DELETE(S49,I)
    NEXT I
   *---- GO BACKWARDS THROUGH THE LIST ----*
    MAX=DCOUNT(S49,@AM) ; * MAX SHOULD BE AT LEAST = 2
   *---- FIRST ONE IT FINDS SHOULD BE *THIS* PROGRAM ----*
    CTR=0 ; * 1=GET.CALLING.STACK
          ; * 2=Current runing program
          ; * 3=routine that 'called' current running program
*
    FOR I=MAX TO 1 STEP -1
       CTR+=1
       THING=S49<I,2>
       THING=CONVERT("/",@VM,THING) ; MAX=DCOUNT(THING,@VM)
       PGM=THING<1,MAX>
       IF PGM[1,1]="_" THEN PGM=PGM[2,999]
       FILE=THING<1,MAX-1>
       ACCT=THING<1,MAX-2>
      *---- ----*
       IF PGM=THIS.PGM THEN
          * NO NEED TO PUT THIS ON THE STACK
       END ELSE
          IF LEN(SPECIFIC) THEN
             BEGIN CASE
                CASE SPECIFIC="M" AND CTR=2 ; OK=1
                CASE SPECIFIC="C" AND CTR=3 ; OK=1
                CASE SPECIFIC="I" AND I=1   ; OK=1
                CASE 1 ; OK=0
             END CASE
          END ELSE
             OK=1
          END
         *---- ----*
          IF OK THEN
             STACK<-1>=FILE:" ":PGM
             IF LEN(SPECIFIC) THEN EXIT
          END
       END
    NEXT I
   *---- ----*
    RETURN STACK
END



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Martin
Hutchinson
Sent: Tuesday, May 30, 2006 6:32 AM
To: [email protected]
Subject: [U2] Knowing where you have come from in a Unibasic subroutine


I am looking for a command or method to determine where a Unibasic
subroutine
has been called from. Something similar to when you execute a debug
statement
and type '?'. Unidata obviously knows where it is when executing a called
subroutine but can I get my hands on it at runtime? Any comments or ideas
gratefully received.

regards

Martin Hutchinson
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

______________________________________________________________________
This e-mail has been scanned by MCI Managed Email Content Service, using
Skeptic(tm) technology powered by MessageLabs. For more information on MCI's
Managed Email Content Service, visit http://www.mci.com.
______________________________________________________________________


______________________________________________________________________
This e-mail has been scanned by MCI Managed Email Content Service, using 
Skeptic(tm) technology powered by MessageLabs. For more information on MCI's 
Managed Email  Content Service, visit http://www.mci.com.
______________________________________________________________________
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to