/*REXX*/
/*--- XDETREXX - Determine REXX Interpreter - 2019 - Mark McDonald ---*/
/*                                MS/PCDOS/DOSBOX/WIN/Unix/Linux      */
/* Determines Which of 46 REXX Interpreters is Running                */
/* Returns REXX 0-45 OS TN ADDRESS() Source Version                   */
/*--------------------------------------------------------------------*/
/*  TRACE R */
    SAY XDETREXX()               ;/* Get REXX/OS Info             */
/*  IF ADDRESS() = "SYSTEM" THEN
       CALL XCMD 'ls'
    ELSE
       CALL XCMD 'DIR / | MORE' */
    PULL Z
 EXIT
/*--------------------------------------------------------------------*/
XDETREXX: PROCEDURE
 parse version TN level dt1 dt2 dt3
 parse source S1
 TA = ADDRESS()
 TOS = TRANSLATE(WORD(S1,1))
 TSPF = 0
 /*say TN;say level;say dt1;say dt2;say dt3;say s1;say tos*/
 /*--  Determine which REXX interpreter is being used ---*/
 /*--- IBM ---                                REXX# OS   TN         Note*/
 IF TN = "REXXPC88"                 THEN TSPF = ' 0 DOS  REXX88  ';/* MSDOS    - IBM (1987)*/
 IF TN = "REXXSAA" THEN DO
    IF (dt3 = "1994" & dt2 = "Nov") THEN TSPF = ' 1 DOS  IBMSAA  ';/* PCDOS    - IBM - Charles Daney*/
    IF TOS = "OS/400"               THEN TSPF = ' 2 AS4  IBMSAA  ';/* AIX/400  - IBM*/
    IF LEFT(TOS,3) = "WIN"          THEN TSPF = ' 3 WIN  OBJREXX ';/* OBJREXX  - IBM*/
 END
 IF TN = "REXX/2" THEN DO
    IF dt3 = "1995"                 THEN TSPF = ' 4 DOS  SPFPC4  ';/* SPFPC4   - IBM REXX/Command Technology Corp*/
    IF dt3 = "1996"                 THEN TSPF = ' 5 WIN  SPFPRO  ';/* SPFPRO   - IBM REXX/Command Technology Corp*/
 END
 IF (TN = "REXX" & dt3 = "99")      THEN TSPF = ' 6 DOS  CREXX   ';/* Compact  - Brian Marks*/
 IF (TN = "OBJREXX" & TA = "bash")  THEN TSPF = ' 7 NIX  OBJREXX ';/*OBJREXX   - IBM Linux*/
 IF TN = "REXXC370"                 THEN TSPF = ' 8 MVS  C370    ';/* REXXC370 - IBM MVS - Compiled REXX*/
 IF TN = "REXX370" THEN DO
    IF TA = "CMS"                   THEN TSPF = ' 9 VM   370     ';/* REXX370  - IBM VM/ESA*/
    IF TA = "ksh"                   THEN TSPF = '10 AIX  SAA     ';/* REXXSAA  - IBM AIX/6000*/
    IF TA = "MVS"                   THEN TSPF = '11 MVS  370     ';/* REXX370  - IBM MVS*/
    IF TA = "REXXCICS"              THEN TSPF = '12 OMVS 370     ';/* REXX370  - IBM OMVS*/
    IF TA = "SH"                    THEN TSPF = '13 OMVS 370     ';/* REXX370  - IBM OMVS*/
    IF TA = "TSO"                   THEN TSPF = '14 TSO  370     ';/* REXX370  - IBM MVS*/
    IF TA = "VSE"                   THEN TSPF = '15 VSE  370     ';/* REXX370  - IBM VSE*/
    IF TA = "XEDIT"                 THEN TSPF = '16 XED  370     ';/* REXX370  - IBM*/
 END
 IF TOS = "OS/2" THEN DO
    IF dt3 = "1996"                 THEN TSPF = '17 OS2W OBJREXX ';/* OBJREXX  - IBM - OS2/WARP4*/
    IF dt3 = "1992"                 THEN TSPF = '18 OS2  IBMSAA  ';/* REXXSAA  - IBM - OS2/2.0*/
    IF (dt3 = "1996" & dt1 = "24")  THEN TSPF = '19 OS24 IBMSAA  ';/* REXXSAA  - IBM - OS2/4.0*/
    IF (dt3 = "1997" & dt1 = "14")  THEN TSPF = '20 OS23 TRITUS  ';/* REXXSAA  - TRITUS 1.2.8 - OS2/3*/
 END
 /*--- Kilowatt ---*/
 IF TN = "REXX-r4"                  THEN TSPF = '21 WIN  R4      ';/* R4       - Kilowatt Classic*/
 IF LEFT(TN,8) = "REXX-roo"         THEN TSPF = '22 WIN  ROO     ';/* ROO      - Kilowatt*/
 /*--- Personal REXX ---*/
 IF POS("Personal",TN) > 0 THEN DO
    IF dt3 = "1992"                 THEN TSPF = '23 DOS  PREXX4  ';/* PREXX    - Mansfield v4*/
    IF dt3 = "1995"                 THEN TSPF = '24 WIN  PREXX4  ';/* PREXX    - Mansfield V4*/
    IF dt3 = "1997"                 THEN TSPF = '25 WIN  PREXX4  ';/* PREXX    - Mansfield v4*/
 END
 /* --- THE Editor ---*/
 IF TA = "THE" THEN DO
    IF TOS = "WIN32"                THEN TSPF = '26 WIN  THE     ';/* REGINA   - Mark Hessling*/
    IF TOS = "UNIX"                 THEN TSPF = '27 NIX  THE     ';/* REGINA   - Mark Hessling*/
    IF TOS = "DOS"                  THEN TSPF = '28 DOS  THE     ';/* REGINA   - Mark Hessling*/
    IF TOS = "OS/2"                 THEN TSPF = '29 OS2  THE     ';/* REGINA   - Mark Hessling*/
 END
 /*--- Regina ---*/
 IF POS("Regina",TN) > 1 THEN DO
    IF TOS = "WIN32"                THEN TSPF = '30 WIN  REGINA  ';/* REGINA   - Mark Hessling*/
    IF TOS = "VMS"                  THEN TSPF = '31 OVMS REGINA  ';/* REGINA   - Mark Hessling*/
    IF TOS = "UNIX"                 THEN TSPF = '32 NIX  REGINA  ';/* REGINA   - Mark Hessling*/
    IF LEFT(TOS,4) = "EPOC"         THEN TSPF = '33 EPCC REGINA  ';/* REGINA   - Mark Hessling*/
    IF TOS = "QNX"                  THEN TSPF = '34 QNX  REGINA  ';/* REGINA   - Mark Hessling*/
    IF LEFT(S1,5) = "AMIGA"         THEN TSPF = '35 AMIG REGINA  ';/* REGINA   - Mark Hessling*/
 END
 /*--- ooRexx ---*/
 IF POS("ooRexx",TN,1) > 1 THEN DO
    IF LEFT(TOS,3) = "WIN"          THEN TSPF = '36 WIN  OOREXX  ';/* OOREXX   - Open Object REXX*/
    IF TOS = "LINUX"                THEN TSPF = '37 NIX  OOREXX  ';/* OOREXX   - LINUX Open Object REXX*/
 END
 /*--- BREXX ---*/
 IF LEFT(TN,5) = "brexx" THEN DO
    IF (dt3 = "2003" & dt1 = "Mar") THEN TSPF = '38 DOS  BREXX16 ';/* BREXX16  - Bill N Vlachoudis*/
 END
 IF name = "REXX/PC" & dt3 = "1992" THEN TSPF = '39 DOS  TRITUS  ';/* TSPF     - Tritus 1.2.2 DOS*/
 IF POS("REXX:",name) > 0           THEN TSPF = '40 DOS  TRITUS  ';/* TSPF     - Tritus 1.2.8 DOS*/
 IF TN = "NetRexx"                  THEN TSPF = '41 WIN  NETREXX ';/* NETREXX  - IBM*/
 IF POS("uni-rexx",TN) > 0          THEN TSPF = '42 NIX  UNI-RX  ';/* uni-rexx - The Workstation Group*/
 IF LEFT(TN,8) = "REXX/imc"         THEN TSPF = '43 NIX  IMC-RX  ';/* REXX-imc - Ian Collier*/
 IF TN="ARexx"                      THEN TSPF = '44 AOS  AREXX   ';/* Amiga REXX*/
 IF POS("ise",TN) > 0 & dt3 = "1995" THEN TSPF = '45 WIN Enterprise ';/* Enterprise REXX*/
 TSPF = TSPF""TA
 TSPF = TSPF" "TN" "level" "dt1" "dt2" "dt3" "S1
RETURN (TSPF)
/*--------------------------------------------------------------------*/
XCMD: PROCEDURE
  PARSE ARG TCMD
  TSPF = WORD(XDETREXX(),1)                   ;/*Determine Which REXX */
  IF TSPF > 3 & TSPF < 6 THEN DO
     IF TSPF =  4 THEN ADDRESS COMMAND TCMD   ;/*SPFPC4*/
     IF TSPF =  5 THEN ADDRESS COMMAND TCMD   ;/*SPFPRO*/
     RETURN
  END
  ELSE DO
    TCMD                                      ;/*Other Interpreters   */
  END
RETURN
/*-------------------------------------------------------------------*/