home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / HSCROLL.PRG < prev    next >
Encoding:
Text File  |  1991-06-28  |  2.8 KB  |  78 lines

  1. /*
  2.     Program: HSCRNSCRL()
  3.     System: GRUMPFISH LIBRARY
  4.     Author: Greg Lief
  5.     Copyright (c) 1988-90, Greg Lief
  6.     Clipper 5.x Version
  7.     Compile instructions: clipper vscroll /n/w/a
  8.  
  9.     Displays screen in horizontal column-by-column increments
  10.  
  11.     NOTE: screen must be pre-saved to the <screen file> using
  12.     Save_Drape())
  13.  
  14.     Syntax: HSCRNSCRL(<screen file> [, <nDirection> ])
  15.  
  16.     Optional parameter <nDirection> determines whether display is left
  17.     to right or vice versa.  1 = right to left, -1 = left to right.
  18.     (Default is left-to-right.)  Thanks to Evan Davies for the
  19.     inspiration!
  20.  
  21.     WILL HANDLE 25/43/50 ROW DISPLAYS
  22. */
  23.  
  24. //───── begin preprocessor directives
  25.  
  26. #include "fileio.ch"
  27. #include "grump.ch"
  28.  
  29. //───── end preprocessor directives
  30.  
  31. function HScrnScrl(cfile, ndirection)
  32. local maxrow := maxrow() + 1, maxcol := maxcol() + 1
  33. local handle, screen_[maxcol], buffer, xx, yy, bufflen := maxrow * 2, buffer2
  34. local loopers_
  35. default ndirection to -1                // default is pull-down
  36. if file(cfile)
  37.    handle := fopen(cfile, FO_READ)
  38.    if handle != F_ERROR
  39.       //───── verify that this file was saved in the same mode that we are in
  40.       //───── because if it wasn't, all hell will break loose further down
  41.       if ( xx := fseek(handle, 0, FS_END) ) == maxrow * maxcol * 2 .or. ;
  42.                                          xx == (maxrow * maxcol * 2) + 4
  43.          buffer := space(bufflen)
  44.          fseek(handle, (xx - maxrow * maxcol * 2), FS_SET) // reset to start
  45.          for xx = 1 to maxcol
  46.             fread(handle, @buffer, bufflen)
  47.             screen_[xx] := buffer
  48.          next
  49.          fclose(handle)
  50.          /*
  51.              load LOOPERS_ array based on direction -- structure is:
  52.                   LOOPERS_[1] := starting row for FOR..NEXT loop
  53.                   LOOPERS_[2] := ending row for FOR..NEXT loop
  54.                   LOOPERS_[3] := leftmost column of region to be shifted
  55.                   LOOPERS_[4] := rightmost column of region to be shifted
  56.                   LOOPERS_[5] := column to be newly displayed
  57.          */
  58.          if ndirection == 1
  59.             loopers_ := { 1, maxcol, 1, maxcol - 1, maxcol }
  60.          else
  61.             loopers_ := { maxcol, 1, 0, maxcol - 2, 0 }
  62.          endif
  63.          for xx = loopers_[1] to loopers_[2] step ndirection
  64.             buffer2 := savescreen(0, loopers_[3], maxrow - 1, loopers_[4])
  65.             restscreen(0, loopers_[5],  maxrow - 1,  loopers_[5], screen_[xx])
  66.             restscreen(0, loopers_[3] - ndirection,  maxrow - 1, ;
  67.                           loopers_[4] - ndirection, buffer2)
  68.          next
  69.       endif
  70.    endif
  71. endif
  72. return NIL
  73.  
  74. * end function HScrnScrl()
  75. *--------------------------------------------------------------------*
  76.  
  77. * eof hscroll.prg
  78.