home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ex_exe.zip / e.cmd next >
OS/2 REXX Batch file  |  2002-04-09  |  3KB  |  87 lines

  1. /*****************************************************************************/
  2. /* Intelligent E                             (c) 1993 by Carsten Wimmer      */
  3. /* For use with Rexx/2                                   cawim@train.fido.de */
  4. /* Modified 2002 by David Mediavilla <davidme * bigfootNO.SPAMcom> */
  5. /*****************************************************************************/
  6. /* This is a small rexx script that blows some intelligence into the         */
  7. /* system editor of OS/2. I always hated E for asking me to associate        */
  8. /* a file type. This script takes care of the file type and prevents E       */
  9. /* from asking anymore.                                                      */
  10. /* Send suggestions and bug-reports to my email address.                     */
  11. /*****************************************************************************/
  12.  
  13. signal on novalue name errorHandling
  14. /* Load the system functions */
  15. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  16. Call SysLoadFuncs
  17.  
  18. /* Get the filename from the command-line and convert it to upper case */
  19. parse upper arg file
  20. parse arg filePreservingCase
  21.  
  22. if( ''¬= file) then do
  23.     if( ''¬= stream( file, 'c', 'query exists')) then do
  24.     /* The file exists */
  25.         /* Save the extension for later reference (only if there is one!) */
  26.         dotPosition= lastpos( '.', file)
  27.         if 0== dotPosition then ext= ''
  28.         else
  29.             if dotPosition > lastpos( '\', file) then,
  30.                 parse upper value substr( file, dotPosition),
  31.                 /* This includes the dot in the extension */ with ext
  32.             else ext=''
  33.  
  34.         /* If there is already an associated file type, skip the rest */
  35.         /* There will be an error trying to get the EA from a filesystem
  36.             with no EAs */
  37.         call SysGetEA file, ".TYPE", "typeinfo" 
  38.         if 0== result then do
  39.             parse var typeinfo 11 oldtype
  40.             if oldtype == "" then do
  41.                 /* Set file type according to the extension */
  42.                 select
  43.                     when ".CMD"== ext then
  44.                         newtype = "OS/2 Command File"
  45.                     when ".BAT"== ext then
  46.                         newtype = "DOS Command File"
  47.                     when ".HTML"== ext | ".HTM"== ext then
  48.                         newtype = "HTML"
  49.                     when ".C"== ext | ".CPP"== ext | ".H"== ext then
  50.                         newtype = "C Code"
  51.                     when ".JAVA"== ext then
  52.                         newtype = "Java Code"
  53.                     otherwise
  54.                         newtype = "Plain Text"
  55.                 end    /* select */
  56.  
  57.                 /* Create EA data */
  58.                   EAdata = 'DFFF00000100FDFF'x || d2c(length(newtype)) ,
  59.                       || '00'x || newtype
  60.                 /* Write EA data to the file */
  61.                   call SysPutEA file, ".TYPE", EAdata            
  62.             end    /* oldtype== "" */ 
  63.         end    /* No error when Getting the EA */
  64.     end    /* The file exists*/
  65.  
  66.     /* Finally, start E */
  67.     /* Even with /f, E doesn't come to the foreground. Strange */
  68.     /* strip removes the " and " inserted automatically when the filename has blanks */
  69.     'start "E - ' strip( filePreservingCase, , '"' ) '" /f e.exe' filePreservingCase
  70.     end    /* There are parameters */
  71. else do    /* No parameters */
  72.     'start "E" /f e.exe'
  73.      end    /* No parameters */
  74. exit rc    
  75.  
  76. errorHandling:
  77.    call LineOut 'STDERR:', 'Error "' condition( 'condition') '" happened'
  78.    call LineOut 'STDERR:', 'Error processing "' condition('description') '"'
  79.    call LineOut 'STDERR:', 'Line ' sigl
  80.    call LineOut 'STDERR:', 'RC= ' rc
  81.    call LineOut 'STDERR:', 'RESULT= ' result
  82. exit
  83.  
  84.  
  85.    
  86.  
  87.