home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / texipf22.zip / texi2ipf / texi2i.cmd < prev    next >
OS/2 REXX Batch file  |  1997-07-17  |  4KB  |  147 lines

  1. /*
  2. **++
  3. ** $Id: texi2i.cmd,v 1.1.1.1 1997/07/17 13:49:26 HERBERT Exp $
  4. **
  5. ** REXX: texi2i.cmd
  6. **
  7. ** FUNCTION:
  8. **    converts a texinfo file to an OS/2 INF file
  9. **    and creates a program object for it on the desktop
  10. **
  11. ** USES:
  12. **
  13. ** AUTHOR: Hans-Michael Stahl <hmstahl@berlin.snafu.de>
  14. **
  15. ** CREATED: 14-Feb-1097
  16. **
  17. ** $Log: texi2i.cmd,v $
  18. ** Revision 1.1.1.1  1997/07/17 13:49:26  HERBERT
  19. ** Texi2IPF 2.2 new import
  20. **
  21. **--
  22. **/
  23.  
  24. /* set up handlers for error situations */
  25.    signal on Syntax
  26.    signal on Halt
  27.    signal on Novalue
  28.  
  29. /* load support functions */
  30.  
  31.    /* REXX utility functions */
  32.    rc = rxfuncadd('sysLoadFuncs', 'REXXUTIL', 'sysLoadFuncs')
  33.    rc = sysLoadFuncs()
  34.  
  35. /* Main program goes here */
  36.  
  37.    /* check environment */
  38.    ipfc = value('IPFC',, 'OS2ENVIRONMENT')
  39.    if ipfc = '' then do
  40.      say  '*Warning*: The IPFC environment variable should be set to the IPFC'
  41.      say  'subdirectory (normally in TOOLKT20) for IPFC to work correctly.'
  42.      exit 1
  43.    end
  44.  
  45.    /* Get general information */
  46.    parse source opSys mode procedureName
  47.  
  48.    /* get arguments */
  49.    parse arg texiFile options
  50.    if texiFile = '' then do
  51.      call usage
  52.      exit 1
  53.    end
  54.  
  55.    /* parse options */
  56.    delete = 1
  57.    object = 1
  58.  
  59.    do i = 1 to words(options)
  60.       opt = translate(word(options, i))
  61.       if left(opt, 1) <> '/' & left(opt,1) <> '-' then iterate
  62.       else opt = substr(opt, 2)
  63.       if abbrev('KEEP', opt, 1) then delete = 0
  64.       if abbrev('NOOBJECT', opt, 3) then object = 0
  65.    end /* do */
  66.    
  67.    /* search texinfo file */
  68.    if lastpos('.', filespec('Name', texiFile)) = 0 then
  69.       rc = SysFileTree(texiFile'.tex*', 'files', 'FO', )
  70.    else
  71.       rc = SysFileTree(texiFile, 'files', 'FO', )
  72.    if files.0 = 0 then do
  73.       say 'No matching file found.'
  74.       exit 1
  75.    end
  76.    if files.0 > 1 then do
  77.       say 'Too many matching files found; be more specific.'
  78.       exit 1
  79.    end
  80.    texiFile = files.1
  81.  
  82.    /* now convert */
  83.    texiName = files.1
  84.    name = filespec('name', texiName)
  85.    path = filespec('drive', texiName)||filespec('path', texiName)
  86.    basename = substr(name, 1, lastpos('.', name)-1)
  87.    ipfName = path||basename'.ipf'
  88.  
  89.    '@texi2ipf' texiName '>' ipfName 
  90.    if rc <> 0 then do
  91.       say 'TEXI2IPF failed with return code' rc
  92.       exit 1
  93.    end
  94.    '@ipfc' ipfName '/INF /S'
  95.    if rc <> 0 then do
  96.       say 'IPFC failed with return code' rc
  97.       exit 1
  98.    end
  99.    if delete then rc = sysFileDelete(ipfName)
  100.    else say 'IPF file kept in 'ipfName '(option /KEEP specified)'
  101.  
  102.    /* create program object */
  103.    if object then do
  104.       location = '<WP_DESKTOP>'
  105.       program = 'EXENAME=VIEW.EXE;PARAMETERS='basename';STARTUPDIR='path
  106.       rc = SysCreateObject("WPProgram", basename , location, program, "f")
  107.       if rc then say 'Object "'basename'" created on desktop'
  108.       else say 'Could not create object "'basename'" on desktop'
  109.    end
  110.    else say 'No object created on desktop (option /NOOBJECT specified)'
  111.       
  112.    exit
  113.  
  114. usage:
  115.    say ''
  116.    say 'Usage: 'procedureName' file [/option...]'
  117.    say ''
  118.    say '  If you do not specify an extension we search for "file.tex*"'
  119.    say '  Option /K[EEP] keeps the IPF source file'
  120.    say '  Option /NOO[BJECT] does not generate a desktop object'
  121.    return
  122.  
  123.  
  124.  
  125. /* procedures */
  126. Syntax:
  127.    say 'A SYNTAX condition was raised on line' sigl'!'
  128.    say '  The error number is' rc', which means "'errortext(rc)'"'
  129.    problem_line = sigl
  130.    signal Abnormal_End
  131.  
  132. Halt:
  133.    say 'A Halt condition was raised on line' sigl'!'
  134.    problem_line = sigl
  135.    rc = 99
  136.    Signal Abnormal_End
  137.  
  138. Novalue:
  139.    say 'Novalue Condition raised on line' sigl'!'
  140.    say '  The variable which caused it is' condition('Description')
  141.    problem_line = sigl
  142.    signal Abnormal_End
  143.  
  144. Abnormal_End:
  145.    Say '  That line is "'Sourceline(problem_line)'"'
  146.    exit rc
  147.