home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 283.lha / AmigaLibHost_v0.9 / avfonts.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1989-09-07  |  1.9 KB  |  105 lines

  1. /*  AVAILABLE FONTS -- A arexx script that uses AmigaLibHost. */
  2.  
  3. /*  USAGE: rx avfonts  */
  4.  
  5.  
  6. /* Access arexx host. */
  7.  
  8. call ADDLIB 'AmigaLibHost',-20
  9.  
  10.  
  11. /* Ask host to open a library. If can't, scram. */
  12.  
  13. DISKFONTBASE = FINDLIB('diskfont.library',0)
  14.  
  15. if DISKFONTBASE = 0 then do
  16.     say 'Can''t open diskfont.library'
  17.     exit
  18. end
  19.  
  20. /* We'll be calling this function. */
  21.  
  22. AVAILFONTS.BASE = DISKFONTBASE
  23. AVAILFONTS.LVO = -36
  24. AVAILFONTS.CALL = '(BUFFER,BUFBYTES,FLAGS)(A0,D0/D1)'
  25.  
  26. AVAILFONTS.BUFFER = 'LONG'
  27.  
  28.  
  29. /* Get memory for buffer. */
  30.  
  31. mem = getspace(1000)
  32.  
  33.  
  34. /* Ask system to find all known memory and disk fonts. */
  35.  
  36. need = SENDLIB('AVAILFONTS',mem,1000,3)
  37.  
  38. /* if need greater that zero, need bigger buffer. */
  39.  
  40. if need ~= 0 then do
  41.  
  42.     freespace(mem,1000)
  43.     mem = getspace(1000 + need)
  44.  
  45.     need = SENDLIB('AVAILFONTS',mem,1000 + need,3)
  46.  
  47.     /* If failed this time, scram. */
  48.  
  49.     if need ~= 0 then do
  50.         say 'Unable to get available fonts'
  51.         exit
  52.     end
  53. end
  54.  
  55.  
  56. /* Convert from 'packed' variable to rexx number. */
  57.  
  58. rxmem = c2d(mem,4)
  59.  
  60. num = PEEK(rxmem,2)
  61. say 'Found ' || num || ' fonts in memory and/or on disk.'
  62.  
  63. do i = 0 to num - 1
  64.  
  65.     /* Get font location. */
  66.  
  67.     val = PEEK(rxmem + 2 + i * 10,2)
  68.     if val = 1 then where = 'MEMORY: '
  69.     if val = 2 then where = 'DISK  : '
  70.     if val = 3 then where = 'BOTH  : '
  71.  
  72.     /* Get font name. */
  73.  
  74.     val = PEEK(rxmem + 4 + i * 10,4)
  75.     name = import(d2c(val,4))
  76.  
  77.     /* Get font size. */
  78.  
  79.     val = PEEK(rxmem + 8 + i * 10,2)
  80.  
  81.     say where || name || " - size " || val
  82. end
  83.  
  84.  
  85. /* Close library. */
  86.  
  87. call DONELIB(DISKFONTBASE)
  88.  
  89. exit        /* don't let 'internal functions' get executed */
  90.  
  91.  
  92. /* Peek function -- sort of like BASIC. */
  93.  
  94. PEEK:
  95. arg location,size
  96. return c2d( import( d2c(location,4),size ),size )
  97.  
  98.  
  99. /* Poke function -- sort of like BASIC. */
  100.  
  101. POKE:
  102. arg location,value,size
  103. call export( d2c(location,4),d2c(value,size),size )
  104. return
  105.