home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 17.12 Popcalend
- Author: Joe Booth
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- //───── NOTE: must compile with the /N option!
-
- #include "INKEY.CH"
- #include "BOX.CH"
-
- function popcalend(cProc,nLine,cVar)
- LOCAL back_scr := savescreen(8, 20, 17, 50)
- LOCAL wmonth := month(date()), nkey := 1
- LOCAL oldcurs := setcursor(0)
- /*********************************
- *▒▒▒ Paint calendar on screen ▒▒▒*
- *********************************/
- @ 08,20,17,50 box B_SINGLE_DOUBLE+" "
- draw_cal( wmonth )
- /***************************
- *▒▒▒ Main calendar loop ▒▒▒*
- ****************************/
- while !empty(nKey)
- nKey := inkey(0)
- do case
- case nKey == K_ESC
- nKey := 0
- loop
- case nKey == K_PGDN
- if ++wmonth > 12
- wmonth :=1
- endif
- draw_cal( wmonth )
- case nKey == K_PGUP
- if --wmonth < 1
- wmonth :=12
- endif
- draw_cal( wmonth )
- case nKey == K_HOME
- wmonth :=1
- draw_cal( 1 )
- case nKey == K_END
- wmonth := 12
- draw_cal( 12 )
- endcase
- enddo
- restscreen(8,20,17,50,back_scr)
- setcursor(oldcurs)
- return NIL
-
- function draw_cal(nMonth)
- LOCAL jj,tt,temp:=str(nMonth,2)+"/01/91"
- LOCAL start := dow(ctod(temp))-1,pday:=0
- LOCAL temp1 := str(if(nMonth<12,nMonth+1,1),2) + "/01/91"
- LOCAL last := day(ctod(temp1)-1)
- @ 9,21 clear to 16,49
- @ 9,21 say padc(cmonth(ctod(temp)),28)
- @ 10,21 say " Sun Mon Tue Wed Thu Fri Sat"
- for jj=1 to 6
- Devpos(10+jj,21)
- for tt=1 to 7
- if ((tt<start+1) .and. jj=1) .or. pday >= last
- ?? space(4)
- else
- ?? str(++pday,4)
- endif
- next
- next
- return NIL
-
- // end of file CHP1712.PRG
-