home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / embeta0.zip / TEXIT.CMD < prev    next >
OS/2 REXX Batch file  |  1992-06-23  |  2KB  |  72 lines

  1. /* texit.cmd -- Copyright (c) 1992 by Eberhard Mattes          */
  2.  
  3. /* Choose TeX format according to first line of TeX input file */
  4. /* Call editor if TeX has been left by answering `E'.          */
  5.  
  6. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  7. call SysLoadFuncs
  8. ver = SysOS2Ver()
  9. if ver >= 2 then
  10.   texprog = 'tex386.exe'
  11. else
  12.   texprog = 'texp.exe'
  13. emtexdrv = value( 'EMTEXDRV',, 'OS2ENVIRONMENT')
  14. if (length( emtexdrv) = 1) & (((emtexdrv >= 'a') & (emtexdrv <= 'z')) |,
  15.                               ((emtexdrv >= 'A') & (emtexdrv <= 'Z'))) then
  16.   emtexdrv = emtexdrv':'
  17. else
  18.   emtexdrv = ''
  19. texpath = SysSearchPath( 'PATH', texprog)
  20. if texpath = '' then texpath = 'texp.exe'
  21. format = ''; options = ''
  22. parse arg arg1 rest
  23. do while (length( arg1) >= 2) & ((substr( arg1, 1, 1) = '-') |,
  24.                                  (substr( arg1, 1, 1) = '/'))
  25.   options = options arg1
  26.   parse var rest arg1 rest
  27. end
  28. if (length( arg1) >= 2) & ((substr( arg1, 1, 1) = '&') |,
  29.                            (substr( arg1, 1, 2) = '^&')) then
  30. do
  31.   format = arg1
  32.   parse var rest arg1 rest
  33. end
  34. if (format = '') & (length( arg1) >= 1) & \ (substr( arg1, 1, 1) = '\') then
  35. do
  36.   input = arg1
  37.   fname = filespec( 'name', input)
  38.   parse var fname base '.' ext
  39.   if ext = '' then
  40.     input = input'.tex'
  41.   fname = stream( input, 'C', 'QUERY EXISTS')
  42.   if fname = '' then
  43.   do
  44.     fname = SysSearchPath( 'TEXINPUT', input)
  45.     if fname = '' then
  46.       fname = stream( emtexdrv'\emtex\texinput\'input, 'C', 'QUERY EXISTS')
  47.   end
  48.   if \ (fname = '') then
  49.   do
  50.     line = linein( fname)
  51.     dummy = stream( input, 'C', 'CLOSE')
  52.     /* say 'First line =' line */
  53.     parse var line '%' 'Format:' format .
  54.     if (format = '') then
  55.       parse var line '%' 'format:' format .
  56.     if (format = '') then
  57.       parse var line '%' 'Format' format .
  58.     if (format = '') then
  59.       parse var line '%' 'format' format .
  60.     if \ (format = '') then format = '^&'format
  61.   end
  62. end
  63. tmpfile = SysTempFileName('texit???.cmd')
  64. '@'texpath '/a='tmpfile options format arg1 rest
  65. if \ (stream( tmpfile, 'C', 'QUERY EXISTS') = '') then
  66. do
  67.   '@call' tmpfile
  68.   '@del' tmpfile
  69. end
  70.  
  71. /* End of texit.cmd */
  72.