home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP17.EXE / CHP1706.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1.3 KB  |  54 lines

  1. /*
  2.    Listing 17.6 Pushdbf() / Popdbf()
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. //───── NOTE: must compile with the /N option!
  12.  
  13. STATIC dbfstack_ :={}
  14.  
  15. function Pushdbf( cAlias )
  16. if cAlias <> NIL
  17.    select select(cAlias)
  18. endif
  19. aadd(dbfstack_, Dbfarray() )
  20. return NIL
  21.  
  22.  
  23. function popdbf( nCount )
  24. LOCAL i, nWork:=0, nOrder:=0, nRec:=0, cFilter:=""
  25. LOCAL nSize := len(dbfstack_)
  26. nCount := if(nCount=NIL,1,nCount)
  27. for i = 1 to nCount
  28.    nWork   := dbfstack_[nSize,1]
  29.    nOrder  := dbfstack_[nSize,2]
  30.    nRec    := dbfstack_[nSize,3]
  31.    cFilter := dbfstack_[nSize,4]
  32.    if !empty(nWork)
  33.       select (nWork)
  34.       set order to (nOrder)
  35.       goto nRec
  36.       if !empty(cFilter)
  37.          dbsetfilter(cFilter)
  38.       endif
  39.    endif
  40.    Asize(dbfstack_,nSize-1)
  41.    nSize --
  42. next
  43. return NIL
  44.  
  45. function DbfArray
  46. LOCAL s_:={}
  47. Aadd( s_,select() )       // Save work area number
  48. Aadd( s_,indexord() )     // Controlling index number
  49. Aadd( s_,recno() )        // Current record number
  50. Aadd( s_,dbfilter() )     // Filter condition
  51. return s_
  52.  
  53. // end of file CHP1706.PRG
  54.