home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / proasm / rexx / asx / sourcemanager.rexx < prev   
OS/2 REXX Batch file  |  1996-04-29  |  5KB  |  166 lines

  1. /******************************************************************************
  2.  *                                                                            *
  3.  * ARexx script:    SourceManager.rexx    for the ASX (ProAsm User Interface) *
  4.  *                                                                            *
  5.  * This script is an example how the source manager of ASX could be used.     *
  6.  *                                                                            *
  7.  * by Daniel Weber                                                            *
  8.  * 30.Jan.94                                                                  *
  9.  *                                                                            *
  10.  *                                                                            *
  11.  * Supported editors, tools:                                                  *
  12.  *  - CygnusEd Professional                                                   *
  13.  *  - TurboText                                                               *
  14.  *  - Edge                                                                    *
  15.  *  - Directory Opus 4.x                                                      *
  16.  *                                                                            *
  17.  ******************************************************************************/
  18.  
  19.  
  20. OPTIONS RESULTS
  21. PARSE ARG source,pubscreen                        /* get arguments */
  22.  
  23.  
  24. /**
  25.  ** handle the 'internal' variables
  26.  ** '$<variable name>:'
  27.  **/
  28. PARSE VALUE source WITH 1 '$'path':'remainder
  29. SELECT
  30.    WHEN UPPER(path)='ASM' THEN source = 'sources:sources/ass/'remainder
  31.    WHEN UPPER(path)='PRO' THEN source = 'sources:sources/pro/'remainder
  32.    WHEN UPPER(path)='NOG' THEN source = 'sources:sources/nog/'remainder
  33.    WHEN UPPER(path)='SRC' THEN source = 'sources:sources/'remainder
  34.    WHEN UPPER(path)='SIM' THEN source = 'sources:sources/newsim/'remainder
  35.    OTHERWISE ;
  36. END
  37.  
  38.  
  39. /**
  40.  ** handle special entries
  41.  **
  42.  ** '*'<source>  : assemble <source>
  43.  ** ';'<comment> : skip
  44.  **
  45.  **/
  46. SELECT
  47.    WHEN LEFT(source,1)='*' THEN DO
  48.       ADDRESS command
  49.       'asm:pro68 '||SUBSTR(source,2)||' -w'
  50.       EXIT(0)
  51.       END
  52.    WHEN LEFT(source,1)=';' THEN EXIT(0)
  53.    OTHERWISE ;
  54. END
  55.  
  56.  
  57. /**
  58.  ** source manager opened on screen xy
  59.  **/
  60.  
  61. /** CygnusEd Professional **/
  62. IF LEFT(pubscreen,14)='CygnusEdScreen' THEN DO
  63.    IF source ~='' THEN DO
  64.      cednumber = RIGHT(pubscreen,1)-1
  65.      IF cednumber = 0 THEN ADDRESS 'rexx_ced'    /* evaluate ced's arexx port */
  66.        ELSE ADDRESS ('rexx_ced'||cednumber)
  67.  
  68.      Jump To File source        /* no need to load the file a second */
  69.      IF (result = 0) THEN DO        /* time...                           */
  70.  
  71.        STATUS 16            /* current size of the active file   */
  72.        FileState = result
  73.        STATUS 18            /* #of changes made to the act. file */
  74.        FileState = FileState + result    /* load it only if no file is loaded */
  75.        IF (FileState ~= 0) THEN DO    /* and no changes are made ...       */
  76.          open new            /* else open a new view  :)          */
  77.          IF (result = 0) THEN DO
  78.            okay1 "Couldn't open a new view!"
  79.            EXIT(0)
  80.          END
  81.        END
  82.        OPEN source            /* load the requested file */
  83.      END
  84.    END
  85. END
  86.  
  87.  
  88.  
  89. /** Edge **/
  90. IF pubscreen='EDGE' THEN DO
  91.    ADDRESS 'EDGE'
  92.    getenvvar _ge_errlevel
  93.    errlevel = result
  94.    New
  95.    IF RC == 0 THEN DO
  96.      ADDRESS value result
  97.      open source
  98.      EXIT(0)
  99.    END
  100.    IF RC >= errlevel THEN DO
  101.      fault
  102.      requestnotify '"'result'"'
  103.      EXIT(0)
  104.    END
  105. END
  106.  
  107.  
  108.  
  109. /** TurboText **/
  110. IF pubscreen='TURBOTEXT' THEN DO
  111.    ADDRESS 'TURBOTEXT'
  112.    OpenDoc
  113.    IF RC==0 THEN DO
  114.      ADDRESS value result
  115.      OpenFile source
  116.      IF RC==0 THEN EXIT(0)
  117.    END
  118.    'SetStatusBar Cound not open file '||source
  119.    EXIT(0)
  120. END
  121.  
  122.  
  123.  
  124. /** Directory Opus 4.x **/
  125. IF LEFT(pubscreen,5)='DOPUS' THEN DO
  126.    IF source ~='' THEN DO
  127.      PARSE VALUE pubscreen WITH 1 remainder '.' dopusnumber
  128.      ADDRESS ('DOPUS.'||dopusnumber)
  129.      status 3                           /* get #of active window      */
  130.      win = result
  131.      tp = POS('/',source)        /* strip filename             */
  132.      IF tp = 0 THEN DO
  133.        PARSE VALUE source WITH 1 source ':'
  134.        source = source||':'
  135.      END
  136.      ELSE DO
  137.        DO WHILE tp~=0
  138.          lp = tp
  139.          tp = POS('/',source,tp+1)
  140.        END
  141.        source = LEFT(source,lp)
  142.      END
  143.      ScanDir source win            /* scan the source's directory */
  144.    END
  145.    EXIT(0)
  146. END
  147.  
  148.  
  149. /**
  150.  ** Workbench
  151.  **
  152.  ** open a new CygnusEd view, or launch CygnusEd...
  153.  ** Required: ED (the CygnusEd Professional activator, here referenced as ED36)
  154.  **/
  155. IF pubscreen='Workbench' THEN DO
  156.    IF source ~='' THEN DO
  157.        ADDRESS COMMAND 'ED36 '||source
  158.    END
  159.    EXIT(0)
  160. END
  161.  
  162.  
  163.  
  164. EXIT(0)
  165.  
  166.