  7H                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 VERSION =   3.00      dataenvironment      dataenvironment      Dataenvironment      Name = "Dataenvironment"
      1      1      form      form      SelDate     1Height = 190
Width = 269
DoCreate = .T.
AutoCenter = .T.
BorderStyle = 2
Caption = "             Select Desired Date"
MaxButton = .F.
MinButton = .F.
WindowType = 1
WindowState = 0
ZoomBox = .F.
BackColor = 255,255,255
selecteddate = {}
ndow = 1
ndim = 31
focusdate = {}
Name = "SelDate"
     	PROCEDURE udbuttons
FOR i = 1 TO 42
  x = 'thisform.dom.b' + ALLT(STR(i))+ '.caption'
  &x = THISFORM.NewString[i]
ENDFOR

ENDPROC
PROCEDURE setdate
PARAMETER FocusDate
* Displays the proper monthly calendar for a +-month/year change or initial date

THISFORM.Label2.CAPTION = CMONTH(FocusDate)+ ' ' + ALLT(STR(YEAR(FocusDate)))

* How many days in the month?
*ThisForm.nDIM = DAY(GOMONTH( CTOD('01/'+'31/'+STR(YEAR(FocusDate))), MONTH(FocusDate)-1))
ThisForm.nDIM = DAY(GOMONTH(DATE(YEAR(FocusDate), 1, 31), MONTH(FocusDate)-1))
 
* What DOW is first day of month?
ThisForm.nDOW = DOW(FocusDate - DAY(FocusDate) + 1)

* Display days of month
FOR i = 1 TO 42
  IF i => ThisForm.nDOW AND i <= ThisForm.nDIM + ThisForm.nDOW - 1
    THISFORM.NewString[i] = STR(i-ThisForm.nDOW+1,2)
  ELSE
    THISFORM.NewString[i] = ' '
  ENDIF
*  x = 'thisform.dom.b' + ALLT(STR(i))+ '.Visible'
*  &x = i => ThisForm.nDOW AND i <= ThisForm.nDIM + ThisForm.nDOW - 1
ENDFOR
THISFORM.UDButtons()

* Focus on current date day
x = 'thisform.dom.b' + ALLT(STR(DAY(FocusDate) + ThisForm.nDOW - 1))+ '.SetFocus'
&x
Thisform.FocusDate = FocusDate



ENDPROC
PROCEDURE Unload
POP KEY
IF EMPTY(Thisform.SelectedDate)
	RETURN Thisform.FocusDate
ELSE
	RETURN Thisform.SelectedDate
ENDIF
ENDPROC
PROCEDURE Init
PARAMETER dStart
PUSH KEY
ON KEY LABEL ESCAPE release window
IF PARAMETERS()>0
  Thisform.FocusDate = dStart
ELSE
  Thisform.FocusDate = DATE()
ENDIF
* initiate the number of days for SelectedDate
*ThisForm.nDIM = DAY(GOMONTH( CTOD('01/'+'31/'+STR(YEAR(Thisform.FocusDate))), MONTH(Thisform.FocusDate)-1))
ThisForm.nDIM = DAY(GOMONTH(DATE(YEAR(Thisform.FocusDate), 1, 31), MONTH(Thisform.FocusDate)-1))

* Find day of week for first day of month
ThisForm.nDOW = DOW(Thisform.FocusDate - DAY(Thisform.FocusDate) + 1)

* draw the calendar
ThisForm.SetDate(Thisform.FocusDate)

* Show current Month/Year on top
THISFORM.Label2.CAPTION = CMONTH(Thisform.FocusDate)+ ' ' + ALLT(STR(YEAR(Thisform.FocusDate)))

* This form Returns the date selected when the day is clicked on
* or empty date if not selected.
* Permits ESC key for cancel
* Form events used are: Init, Unload
* Form added methods in this form are: SetDate, UDButtons
* DOM buttons use the click even
ENDPROC
                                      %   6      a     E            U    T    H      ?  T      d  T        T        T    CC       U  NMONTHSHIFT THISFORM YRMOSEL VALUE SETDATE	 FOCUSDATE Click,     1   q q q q A 1                       v      )                                                        *   %   i           x            U   9 %                   @ T  thisform.dom.bCCC   %   Z	 .SetFocus &x
 B  T        " T   CC   iC   H $ T      
   	  U
  THISFORM DOM VALUE NDOW NDIM X	 FOCUSDATE	 NDAYSHIFT SELECTEDDATE RELEASE Click,     1 a A A "1 1                             )                           !Arial, 0, 9, 5, 15, 12, 13, 3, 0
      Caption = "Sun     Mon     Tue     Wed     Thu       Fri       Sat"
Height = 14
Left = 12
Top = 17
Width = 247
Name = "Label1"
      SelDate      Label1      label      label      ?Top = 14
Left = 2
Height = 19
Width = 266
Name = "Shape1"
      SelDate      Shape1      shape      shape      [selecteddate
dayoffset
ndow
ndim
focusdate
*udbuttons 
^newstring[42,0] 
*setdate 
      commandgroup      commandgroup      DOM      SelDate     mButtonCount = 42
Value = 1
Height = 110
Left = 1
Top = 32
Width = 268
Name = "DOM"
Command1.Top = 2
Command1.Left = 1
Command1.Height = 18
Command1.Width = 38
Command1.Caption = "1"
Command1.Name = "B1"
Command2.Top = 2
Command2.Left = 39
Command2.Height = 18
Command2.Width = 38
Command2.Caption = "2"
Command2.Name = "B2"
Command3.Top = 2
Command3.Left = 77
Command3.Height = 18
Command3.Width = 38
Command3.Caption = "3"
Command3.Name = "B3"
Command4.Top = 2
Command4.Left = 115
Command4.Height = 18
Command4.Width = 38
Command4.Caption = "4"
Command4.Name = "B4"
Command5.Top = 2
Command5.Left = 153
Command5.Height = 18
Command5.Width = 38
Command5.Caption = "5"
Command5.Name = "B5"
Command6.Top = 2
Command6.Left = 191
Command6.Height = 18
Command6.Width = 38
Command6.Caption = "6"
Command6.Name = "B6"
Command7.Top = 2
Command7.Left = 229
Command7.Height = 18
Command7.Width = 38
Command7.Caption = "7"
Command7.Name = "B7"
Command8.Top = 20
Command8.Left = 1
Command8.Height = 18
Command8.Width = 38
Command8.Caption = "8"
Command8.Name = "B8"
Command9.Top = 20
Command9.Left = 39
Command9.Height = 18
Command9.Width = 38
Command9.Caption = "9"
Command9.Name = "B9"
Command10.Top = 20
Command10.Left = 77
Command10.Height = 18
Command10.Width = 38
Command10.Caption = "10"
Command10.Name = "B10"
Command11.Top = 20
Command11.Left = 115
Command11.Height = 18
Command11.Width = 38
Command11.Caption = "11"
Command11.Name = "B11"
Command12.Top = 20
Command12.Left = 153
Command12.Height = 18
Command12.Width = 38
Command12.Caption = "12"
Command12.Name = "B12"
Command13.Top = 20
Command13.Left = 191
Command13.Height = 18
Command13.Width = 38
Command13.Caption = "13"
Command13.Name = "B13"
Command14.Top = 20
Command14.Left = 229
Command14.Height = 18
Command14.Width = 38
Command14.Caption = "14"
Command14.Name = "B14"
Command15.Top = 38
Command15.Left = 1
Command15.Height = 18
Command15.Width = 38
Command15.Caption = "15"
Command15.Name = "B15"
Command16.Top = 38
Command16.Left = 39
Command16.Height = 18
Command16.Width = 38
Command16.Caption = "16"
Command16.Name = "B16"
Command17.Top = 38
Command17.Left = 77
Command17.Height = 18
Command17.Width = 38
Command17.Caption = "17"
Command17.Name = "B17"
Command18.Top = 38
Command18.Left = 115
Command18.Height = 18
Command18.Width = 38
Command18.Caption = "18"
Command18.Name = "B18"
Command19.Top = 38
Command19.Left = 153
Command19.Height = 18
Command19.Width = 38
Command19.Caption = "19"
Command19.Name = "B19"
Command20.Top = 38
Command20.Left = 191
Command20.Height = 18
Command20.Width = 38
Command20.Caption = "20"
Command20.Name = "B20"
Command21.Top = 38
Command21.Left = 229
Command21.Height = 18
Command21.Width = 38
Command21.Caption = "21"
Command21.Name = "B21"
Command22.Top = 56
Command22.Left = 1
Command22.Height = 18
Command22.Width = 38
Command22.Caption = "22"
Command22.Name = "B22"
Command23.Top = 56
Command23.Left = 39
Command23.Height = 18
Command23.Width = 38
Command23.Caption = "23"
Command23.Name = "B23"
Command24.Top = 56
Command24.Left = 77
Command24.Height = 18
Command24.Width = 38
Command24.Caption = "24"
Command24.Name = "B24"
Command25.Top = 56
Command25.Left = 115
Command25.Height = 18
Command25.Width = 38
Command25.Caption = "25"
Command25.Name = "B25"
Command26.Top = 56
Command26.Left = 153
Command26.Height = 18
Command26.Width = 38
Command26.Caption = "26"
Command26.Name = "B26"
Command27.Top = 56
Command27.Left = 191
Command27.Height = 18
Command27.Width = 38
Command27.Caption = "27"
Command27.Name = "B27"
Command28.Top = 56
Command28.Left = 229
Command28.Height = 18
Command28.Width = 38
Command28.Caption = "28"
Command28.Name = "B28"
Command29.Top = 74
Command29.Left = 1
Command29.Height = 18
Command29.Width = 38
Command29.Caption = "29"
Command29.Name = "B29"
Command30.Top = 74
Command30.Left = 39
Command30.Height = 18
Command30.Width = 38
Command30.Caption = "30"
Command30.Name = "B30"
Command31.Top = 74
Command31.Left = 77
Command31.Height = 18
Command31.Width = 38
Command31.Caption = "31"
Command31.Name = "B31"
Command32.Top = 74
Command32.Left = 115
Command32.Height = 18
Command32.Width = 38
Command32.Caption = "32"
Command32.Name = "B32"
Command33.Top = 74
Command33.Left = 153
Command33.Height = 18
Command33.Width = 38
Command33.Caption = "33"
Command33.Name = "B33"
Command34.Top = 74
Command34.Left = 191
Command34.Height = 18
Command34.Width = 38
Command34.Caption = "34"
Command34.Name = "B34"
Command35.Top = 74
Command35.Left = 229
Command35.Height = 18
Command35.Width = 38
Command35.Caption = "35"
Command35.Name = "B35"
Command36.Top = 92
Command36.Left = 1
Command36.Height = 18
Command36.Width = 38
Command36.Caption = "36"
Command36.Name = "B36"
Command37.Top = 92
Command37.Left = 39
Command37.Height = 18
Command37.Width = 38
Command37.Caption = "37"
Command37.Name = "B37"
Command38.Top = 92
Command38.Left = 77
Command38.Height = 18
Command38.Width = 38
Command38.Caption = "38"
Command38.Name = "B38"
Command39.Top = 92
Command39.Left = 115
Command39.Height = 18
Command39.Width = 38
Command39.Caption = "39"
Command39.Name = "B39"
Command40.Top = 92
Command40.Left = 153
Command40.Height = 18
Command40.Width = 38
Command40.Caption = "40"
Command40.Name = "B40"
Command41.Top = 92
Command41.Left = 191
Command41.Height = 18
Command41.Width = 38
Command41.Caption = "41"
Command41.Name = "B41"
Command42.Top = 92
Command42.Left = 229
Command42.Height = 18
Command42.Width = 38
Command42.Caption = "42"
Command42.Name = "B42"
     PROCEDURE Click
IF THISFORM.DOM.VALUE < THISFORM.nDOW  OR THISFORM.DOM.VALUE > THISFORM.nDIM + THISFORM.nDOW -1
  * ignore butons outside month's date range
* ReFocus on current selected date day
x = 'thisform.dom.b' + ALLT(STR(DAY(Thisform.FocusDate) + ThisForm.nDOW - 1))+ '.SetFocus'
&x
  RETURN
ENDIF

nDayShift = THISFORM.DOM.VALUE - THISFORM.nDOW + 1
*Thisform.FocusDate=CTOD(STR(MONTH(Thisform.FocusDate))+'/'+STR(nDayShift)+'/'+STR(YEAR(Thisform.FocusDate)))
ThisForm.FocusDate = DATE(YEAR(Thisform.FocusDate), MONTH(Thisform.FocusDate), nDayShift)
Thisform.SelectedDate = Thisform.FocusDate && the form date returned
ThisForm.Release
ENDPROC
      FontBold = .T.
FontSize = 10
Caption = "Click on selection day"
Height = 20
Left = 64
Top = 173
Width = 142
ForeColor = 128,0,0
BackColor = 255,255,255
Name = "Label3"
      SelDate      Label3      label      label      SelDate      YrMoSel      commandgroup      commandgroup      FontBold = .T.
Alignment = 2
BorderStyle = 0
Caption = "October 1998"
Height = 17
Left = 2
Top = 0
Width = 267
BackColor = 192,192,192
Name = "Label2"
      SelDate      label      label      Label2     zButtonCount = 4
Value = 0
Height = 28
Left = 2
Top = 142
Width = 265
Name = "YrMoSel"
Command1.Top = 1
Command1.Left = 1
Command1.Height = 27
Command1.Width = 66
Command1.Caption = "-Yr"
Command1.Name = "Command1"
Command2.Top = 1
Command2.Left = 67
Command2.Height = 27
Command2.Width = 66
Command2.Caption = "-Mo"
Command2.Name = "Command2"
Command3.Top = 1
Command3.Left = 133
Command3.Height = 27
Command3.Width = 66
Command3.Caption = "+Mo"
Command3.Name = "Command3"
Command4.Top = 1
Command4.Left = 199
Command4.Height = 27
Command4.Width = 66
Command4.Caption = "+Yr"
Command4.Name = "Command4"
     PROCEDURE Click
nMonthShift = 0
DO CASE
CASE THISFORM.YrMoSel.VALUE = 1 && PrevYear
  nMonthShift = -12
CASE THISFORM.YrMoSel.VALUE = 2 && PrevMonth
  nMonthShift = -1
CASE THISFORM.YrMoSel.VALUE = 3 && NextMonth
  nMonthShift = 1
CASE THISFORM.YrMoSel.VALUE = 4 && NextYear
  nMonthShift = 12
ENDCASE

ThisForm.SetDate(GOMONTH(Thisform.FocusDate, nMonthShift))
ENDPROC
     '                              ,j   %           *   A            U  k    (*d / T  thisform.dom.bCC  Z .caption &x = THISFORM.NewString[i]
  U  I Xb 4  $ T   C  !  CCC  iZ' T  CCCC  i$C  H% T  C  C  %)  (* - %         	 & T   C   Z   T        C  = T	  thisform.dom.bCCC  %  Z	 .SetFocus &x
 T      U
 	 FOCUSDATE THISFORM LABEL2 CAPTION NDIM NDOW I	 NEWSTRING	 UDBUTTONS X>   %C   #  B    7  B     U  THISFORM SELECTEDDATE	 FOCUSDATE  4     12 ESCAPE release window %C L  T     c  T  C$ - T  CCCC  i$C  H%" T  C  C  %) C    * T   C  !  CCC  iZ U	  DSTART ESCAPE THISFORM	 FOCUSDATE NDIM NDOW SETDATE LABEL2 CAPTION	 udbuttons,      setdate      UnloadU     Init    1 qA 3 q Ctsa qA C  a 5 Q !   A 2 q Q   A #38                                               )      0  		  1    )                     
