home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 426.lha / Leggi / IFF.rexx < prev    next >
OS/2 REXX Batch file  |  1990-10-02  |  2KB  |  79 lines

  1. /*
  2. *
  3. * This program generates an IFF FTXT file from an ASCII file. The syntax is
  4. *
  5. * IFF infile outfile
  6. *
  7. * To change the fonts inserted in the FTXT file, change the stems "fontname.i.j."
  8. * The first number is the font number, the second number lets you specify many
  9. * alternatives if you wanna be sure that some font will eventually match. The
  10. * LAST (highest number) font matched is the one Leggi will keep. So don't
  11. * exaggerate, or reading your IFF file will take minutes, since every font
  12. * must be opened. NOTE: Comment out the font you're not using!
  13. *
  14. */
  15.  
  16. fontname.='NOFONT'
  17. fontname.1.1='Diamond.font/17'
  18. fontname.2.1='Diamond.font/20'
  19. /*
  20. fontname.3.1='Times.font/18'
  21. fontname.4.1='Times.font/24'
  22. fontname.5.1='Helvetica.font/18'
  23. fontname.6.1='Helvetica.font/24'
  24. fontname.7.1='Garnet.font/9'
  25. fontname.8.1='Garnet.font/16'
  26. */
  27.  
  28. parse arg in ' ' out
  29.  
  30. if open('outfile', out, 'w') == 0 then
  31.     do
  32.         say 'Can''t open output file'
  33.         exit 0
  34.     end
  35.  
  36. rc = writech('outfile', 'FORM');
  37. rc = WriteLongWord(0)
  38. rc = writech('outfile', 'FTXT');
  39.  
  40. do i = 1 to 8
  41.  
  42.     do j=1 while fontname.i.j ~= 'NOFONT'
  43.         l = length(fontname.i.j)
  44.         rc = writech('outfile', 'FONS');
  45.         rc = WriteLongWord(l-(l//2)+6)
  46.         rc = writech('outfile', d2c(i-1)||d2c(0)||d2c(0)||d2c(0))
  47.         rc = writech('outfile', fontname.i.j)
  48.         rc = writech('outfile', d2c(0))
  49.         if l//2 = 0 then rc = writech('outfile', d2c(0))
  50.     end
  51.  
  52. end
  53.  
  54. if open('infile', in, 'r') == 0 then
  55.     do
  56.         say 'Can''t open input file'
  57.         exit 0
  58.     end
  59.  
  60. l = seek('infile', 0, 'e')
  61. rc = seek('infile', 0, 'b')
  62. a = readch('infile', l)
  63.  
  64. rc = writech('outfile', 'CHRS')
  65. rc = WriteLongWord(l+(l//2))
  66. rc = writech('outfile', a)
  67. if l//2 ~= 0 then rc = writech('outfile', d2c(0))
  68. l = seek('outfile', 0, 'e');
  69. rc = seek('outfile', 4, 'b');
  70. rc = WriteLongWord(l-8)
  71.  
  72. exit 0
  73.  
  74.  
  75. WriteLongWord: procedure
  76.     arg n
  77. rc = writech('outfile', right( d2c(0)||d2c(0)||d2c(0)||d2c(n), 4));
  78. return rc
  79.