home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / DRAPES.PRG < prev    next >
Encoding:
Text File  |  1991-04-23  |  2.7 KB  |  94 lines

  1. /*
  2.     Program: DRAPES.PRG
  3.     System: GRUMPFISH LIBRARY
  4.     Author: Greg Lief
  5.     Copyright (c) 1988-90, Greg Lief
  6.     Clipper 5.x Version
  7.     Compile instructions: clipper drapes /n/w/a
  8.  
  9.     Procs & Fncts: PULL_DRAPE()
  10.                  : SAVE_DRAPE()
  11. */
  12.  
  13. //───── begin preprocessor directives
  14.  
  15. #include "grump.ch"
  16. #include "fileio.ch"
  17.  
  18. //───── end preprocessor directives
  19.  
  20. /*
  21.    Function: PULL_DRAPE()
  22.    Purpose:  Draw title screen from specified memory file
  23. */
  24. function Pull_Drape(cfile, ndelay)
  25. local nhandle, screen_ := {}, buffer := space(4), xx, yy, midpoint, ;
  26.       ntop := 0, nleft := 0, nbottom := maxrow(), nright := maxcol(), mwidth, ;
  27.       mlength, oldcurs := setcursor(0)
  28. default ndelay to 20
  29. if file(cfile)
  30.    nhandle := fopen(cfile, FO_READ)
  31.    //───── determine file length
  32.    mlength := fseek(nhandle, 0, FS_END)
  33.    //───── reset pointer to beginning of file
  34.    fseek(nhandle, FS_SET)
  35.    //───── we must accommodate for .scr files created by
  36.    //───── if this is not a full screen
  37.    if mlength != 4000
  38.       fread(nhandle, @buffer, 4)
  39.       ntop    := bin2i(substr(buffer, 1, 1))
  40.       nleft   := bin2i(substr(buffer, 2, 1))
  41.       nbottom := bin2i(substr(buffer, 3, 1))
  42.       nright  := bin2i(substr(buffer, 4, 1))
  43.    endif
  44.    buffer := space( mwidth := ((nbottom - ntop) + 1) * 2 )
  45.    for xx = 1 to nright - nleft + 1
  46.       fread(nhandle, @buffer, mwidth)
  47.       aadd(screen_, buffer)
  48.    next
  49.    fclose(nhandle)
  50.    midpoint := nleft + int((nright - nleft + 1) / 2) + 1
  51.    for xx = midpoint to nright + 1
  52.       restscreen(ntop, xx - 1, nbottom, xx - 1, screen_[xx - nleft])
  53.       restscreen(ntop, nright + 1 + nleft - xx, nbottom, ;
  54.                  nright + 1 + nleft - xx, screen_[nright + 2 - xx])
  55.       for yy = 1 to ndelay
  56.       next
  57.    next
  58. endif
  59. setcursor(oldcurs)
  60. return NIL
  61.  
  62. * end function Pull_Drape()
  63. *--------------------------------------------------------------------*
  64.  
  65.  
  66. /*
  67.      Function: SAVE_DRAPE()
  68.      Purpose:  Save title screen to specified memory file
  69. */
  70. function save_drape(cfile, ntop, nleft, nbottom, nright)
  71. local buffer, nhandle := fcreate(cfile), xx, ret_val := .f.
  72. default ntop to 0
  73. default nleft to 0
  74. default nbottom to maxrow()
  75. default nright to maxcol()
  76. if ferror() = 0
  77.    fwrite(nhandle, chr(ntop) + chr(nleft) + chr(nbottom) + chr(nright))
  78.    ret_val := .t.
  79.    for xx = nleft to nright
  80.       buffer := savescreen(ntop, xx, nbottom, xx)
  81.       if fwrite(nhandle, buffer) != ((nbottom - ntop) + 1) * 2
  82.          ret_val := .f.
  83.          exit
  84.       endif
  85.    next
  86.    fclose(nhandle)
  87. endif
  88. return ret_val
  89.  
  90. * end function Save_Drape()
  91. *--------------------------------------------------------------------*
  92.  
  93. * eof drapes.prg
  94.