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

  1. /*
  2.    Listing 17.12  Popcalend
  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. #include "INKEY.CH"
  14. #include "BOX.CH"
  15.  
  16. function popcalend(cProc,nLine,cVar)
  17. LOCAL back_scr := savescreen(8, 20, 17, 50)
  18. LOCAL wmonth   := month(date()), nkey := 1
  19. LOCAL oldcurs := setcursor(0)
  20. /*********************************
  21. *▒▒▒ Paint calendar on screen ▒▒▒*
  22. *********************************/
  23. @ 08,20,17,50 box B_SINGLE_DOUBLE+" "
  24. draw_cal( wmonth )
  25. /***************************
  26. *▒▒▒ Main calendar loop ▒▒▒*
  27. ****************************/
  28. while !empty(nKey)
  29.    nKey := inkey(0)
  30.    do case
  31.    case nKey == K_ESC
  32.       nKey := 0
  33.       loop
  34.    case nKey == K_PGDN
  35.       if ++wmonth > 12
  36.          wmonth :=1
  37.       endif
  38.       draw_cal( wmonth )
  39.    case nKey == K_PGUP
  40.       if --wmonth < 1
  41.          wmonth :=12
  42.       endif
  43.       draw_cal( wmonth )
  44.    case nKey == K_HOME
  45.       wmonth :=1
  46.       draw_cal( 1 )
  47.    case nKey == K_END
  48.       wmonth := 12
  49.       draw_cal( 12 )
  50.    endcase
  51. enddo
  52. restscreen(8,20,17,50,back_scr)
  53. setcursor(oldcurs)
  54. return NIL
  55.  
  56. function draw_cal(nMonth)
  57. LOCAL jj,tt,temp:=str(nMonth,2)+"/01/91"
  58. LOCAL start := dow(ctod(temp))-1,pday:=0
  59. LOCAL temp1 := str(if(nMonth<12,nMonth+1,1),2) + "/01/91"
  60. LOCAL last := day(ctod(temp1)-1)
  61. @  9,21 clear to 16,49
  62. @  9,21 say padc(cmonth(ctod(temp)),28)
  63. @ 10,21 say " Sun Mon Tue Wed Thu Fri Sat"
  64. for jj=1 to 6
  65.    Devpos(10+jj,21)
  66.    for tt=1 to 7
  67.       if ((tt<start+1) .and. jj=1) .or. pday >= last
  68.          ?? space(4)
  69.       else
  70.          ?? str(++pday,4)
  71.       endif
  72.    next
  73. next
  74. return NIL
  75.  
  76. // end of file CHP1712.PRG
  77.