home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / openinc.lx < prev    next >
Text File  |  1998-02-24  |  3KB  |  92 lines

  1. /* A REXX macro which will open PL/I include files.                                    */
  2.  
  3. /* This macro is a prototype and has a number of development needs:                    */
  4. /*  - the word INCLUDE must be on the same line as the name of the file.               */ 
  5. /*  - it assumes that the file's extension will be .inc it does not have any way of    */
  6. /*    predicting the contents of your 'extensions ' option when you actually compile   */
  7. /*  - it presumes that the environment variable IBM.SYSLIB will be set to the value it */
  8. /*    will have when you actually compile                                              */
  9. /*  - it searches the directories named by the IBM.SYSLIB environment varible to find  */
  10. /*    the include file.                                                                */
  11.  
  12. /* Load the rexx utilities library. */
  13. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  14. call SysLoadFuncs
  15.  
  16. 'extract content' 
  17. 'extract fonts  ' 
  18.  
  19. hit_include = 0 ; 
  20. i = 1 ;
  21. do while ( i <= length(content) & hit_include = 0 ) ;
  22.    if datatype( substr(content,i,1) , 'Mixed Case' ) = 1 then
  23.      do ;
  24.        j = i ;       /* Remember where the word starts. */
  25.        word = '' ;
  26.        do while ( i <= length(content) & datatype( substr(content,i,1) , 'Mixed Case' ) = 1 ) ;
  27.          word = word || substr(content,i,1) ;
  28.          i = i + 1 ;
  29.        end ;
  30.  
  31.        if translate(word) = 'INCLUDE' then 
  32.          /* Check that the parser thinks it's a keyword. */
  33.          if substr(fonts,  j , length(word) ) = 'IIIIIII' then
  34.            hit_include = 1 ;
  35.      end ;
  36.    else
  37.      do ;
  38.        /* Throw away non word characters. */
  39.        do while ( i <= length(content) & datatype( substr(content,i,1) , 'Mixed Case' ) = 0 ) ;
  40.          i = i + 1 ;
  41.        end ;
  42.      end ;
  43. end ;
  44.  
  45. if hit_include = 0 then
  46.   do ; 
  47.     'msg Did not find an INCLUDE on this line.'
  48.     exit ;
  49.   end ;
  50.  
  51. /* Throw away blank characters. */
  52. do while ( i <= length(content) & substr(content,i,1) = ' ' ) ;
  53.    word = word || substr(content,i,1) ;
  54.    i = i + 1 ;
  55. end ;
  56.  
  57. /* Now we may have a comma separated list to process. */
  58. i = i - 1 ; 
  59. do until ( i > length( content ) | substr(content,i,1) ¬= ',' )
  60.   i = i + 1 ;
  61.   /* Throw away blank characters. */
  62.   do while ( i <= length(content) & substr(content,i,1) = ' ' ) ;
  63.      word = word || substr(content,i,1) ;
  64.      i = i + 1 ;
  65.   end ;
  66.  
  67.   /* Collect a word. */
  68.   word = '' ;
  69.   do while ( i <= length(content) & datatype( substr(content,i,1) , 'Alphanumeric' ) ) ;
  70.     word = word || substr(content,i,1) ;
  71.     i = i + 1 ;
  72.   end ;
  73.  
  74.   filespec = SysSearchPath('IBM.SYSLIB' , word || '.inc' ) 
  75.  
  76.   if filespec = '' then
  77.      'msg Unable to locate include file' word || '.inc' 
  78.   else
  79.      'lx' filespec
  80.  
  81.   /* Throw away blank characters. */
  82.   do while ( i <= length(content) & substr(content,i,1) = ' ' ) ;
  83.      word = word || substr(content,i,1) ;
  84.      i = i + 1 ;
  85.   end ;
  86.  
  87.  
  88. end ;
  89.  
  90. 'msg Includes opened' ;
  91. exit  ;
  92.