home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / exodem.zip / TBNET.PRG < prev    next >
Text File  |  1993-06-04  |  5KB  |  147 lines

  1. /*
  2.   ┌─────────────────────────────────────────────────────────────────────────┐
  3.  ▌│                                                                         │
  4.  ▌│   Program  : TBNet.PRG                                                  │
  5.  ▌│   purpose  : Networkable Tbrowse (slightly modified source from         │
  6.  ▌│              Greg Lief's book on Networking with Clipper 5.2)           │
  7.  ▌│   belongs to test series for exospace (beta 1)                          │
  8.  ▌│   author   : Dieter Crispien                                            │
  9.  ▌│   compile  : /m /n /w /a                                                │
  10.  ▌│   link     : exospace fi tbnet exo cl 501                               │
  11.  ▌│   utilities: dbcre8 1000 creates a test.dbf for this                    │
  12.  ▌│   Comment  : TBNet even runs fine  when eating up 370 k using           │
  13.  ▌│              eatmem 370                                                 │
  14.  ▌│              mem /c reports 228 k free memory after this                │
  15.  ▌└─────────────────────────────────────────────────────────────────────────┘
  16.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  17. To get maximum execution speed, do NOT use any memory manager!
  18.  
  19. Testen Sie die Programm-Ausführung mit und ohne Speichermanager!
  20. Auch EMM386 NOEMS ist eine gute Einstellung.
  21. Alle Speichermanager können so eingestellt werden, daß nicht alles
  22. verfügbares Memory als EMS verwaltet wird.
  23.  
  24. Wenn Sie EATMEM haben, oder auf andere Weise möglichst viel Speicher
  25. belegen, werden Sie sehen daß das Programm sogar noch mit unter 250K
  26. freiem Basisspeicher läuft!
  27.  
  28.  
  29.  
  30. */
  31.  
  32. #include "box.ch"
  33. #include "inkey.ch"
  34. #include "setcurs.ch"
  35.  
  36. #define REFRESH_TIME  10
  37.  
  38. field last,first,city,state,salary,hiredate,Notes
  39. memvar GETLIST
  40.  
  41.  
  42. function main
  43.  
  44. local x
  45. local b := TBrowseDB(1, 1, maxrow()-1, maxcol()-1)
  46. local c
  47. local nKey
  48. local nseconds := 0, nTimeDiff
  49. set scoreboard off
  50. setcursor(SC_NONE)
  51. use TEST
  52. if !file("TE_LAST.NTX")
  53.    index on upper(last) to TE_LAST
  54. endif
  55. if !file("TE_SALRY.NTX")
  56.    index on str(salary,8)+dtos(hiredate) to TE_SALRY
  57. endif
  58. USE TEST shared
  59. set index to TE_LAST,TE_SALRY
  60. set order to 2
  61.  
  62. c := TBColumnNew("Last name            First      City"+;
  63.                  "            St hired      salary  days", { || Show() } )
  64. b:HeadSep := "═══"
  65. b:AddColumn( c )
  66. @ b:nTop - 1, b:nLeft - 1, b:nBottom + 1, b:nRight + 1 box B_SINGLE + ' '
  67. @ b:nBottom +1, 5 SAY "Press ALT-M and you'll have a look into memory wonderland!!!" color "+GR/N"
  68. do while nKey != K_ESC
  69.    dispbegin()
  70.    do while ( nKey := inkey() ) == 0 .and. ! b:stabilize(); enddo
  71.    dispend()
  72.    if nKey == 0
  73.       // replacing inkey(0) to refresh every 10 seconds
  74.       do while ( nKey := inkey() ) == 0
  75.          nTimeDiff := Seconds() - nSeconds
  76.          @ 0,2 SAY nTimeDiff PICT "99.9"
  77.          if nTimeDiff > REFRESH_TIME
  78.             nseconds := seconds()
  79.             b:refreshAll()
  80.             dispbegin()
  81.             do while ! b:stabilize(); enddo
  82.             dispend()
  83.          endif
  84.       enddo
  85.    endif
  86.    do case
  87.       case nKey == K_UP;       b:up()
  88.       case nKey == K_DOWN;     b:down()
  89.       case nKey == K_LEFT;     b:left()
  90.       case nKey == K_RIGHT;    b:right()
  91.       case nKey == K_PGUP;     b:pageUp()
  92.       case nKey == K_PGDN;     b:pageDown()
  93.       case nKey == K_CTRL_PGUP;b:goTop()
  94.       case nKey == K_CTRL_PGDN;b:goBottom()
  95.       case nKey == K_ALT_M;    dispmemory()
  96.       case nKey == K_ENTER .or. nKey == 32
  97.            select Test
  98.            if Rlock()
  99.               edit()
  100.               commit; unlock
  101.            else
  102.               Alert( "Someone's working on this record...." )
  103.            endif
  104.    endcase
  105. enddo
  106. dbclosearea()
  107. return nil
  108.  
  109. ******************************************************************************
  110. static function Show()
  111. local nDauer := date() - hiredate
  112. return last+" "+substr(first,1,10)+" "+substr(city,1,15)+" "+state+" "+;
  113.        dtoc(hiredate)+str(salary,9)+" "+str(nDauer,5)
  114.  
  115. ******************************************************************************
  116. static function edit(b)
  117. local cSave  := savescreen(6,10,12,40)
  118.  
  119. dispbox(6,10,12,40,2)
  120. @  7,11 clear to 11,39
  121. @  7,11 say "Last   : "+Test->first
  122. @  8,11 say "First  : "+Test->last
  123. @  9,11 say "hire date      : "+dtoc(Test->hiredate)
  124. @ 10,11 say "salary         : "+str(Test->salary,6)
  125. @ 11,11 say "new salary     :" GET Test->salary
  126. READ
  127. restscreen(6,10,12,40,cSave)
  128. return NIL
  129.  
  130. function dispmemory()
  131. local t:= 5, l := 4, b := 14, r := 51
  132. local cScreen
  133.   cScreen := savescreen(t,l,b,r)
  134.   @ t,l,b,r box B_DOUBLE+" " color "+GR/N"
  135.   @ t+1,l+1 SAY "available swap space..............(0)"+str( memory(0),8)
  136.   @ t+2,l+1 SAY "größter zusammenhängender Block...(1)"+str( memory(1),8)
  137.   @ t+3,l+1 SAY "free for RUN .....................(2)"+str( memory(2),8)
  138.   @ t+4,l+1 SAY "free for variables ...............(3)"+str( memory(3),8)
  139.   @ t+5,l+1 SAY "free not allocated EMM ...........(4)"+str( memory(4),8)
  140.   @ t+6,l+1 SAY "size of fixed heap .............(101)"+str( memory(101),8)
  141.   @ t+7,l+1 SAY "number of segments in fixed heap(102)"+str( memory(102),8)
  142.   @ t+8,l+1 SAY "not allocated conventional memo.(104)"+str( memory(104),8)
  143.   inkey(0)
  144.   restscreen(t,l,b,r,cScreen)
  145. return nil
  146.  
  147.