Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Christof... your Y2k code...
Message
 
To
02/10/1998 17:01:15
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00143466
Message ID:
00143569
Views:
15
>Cristof...
>
>I am trying to use your Y2K code... and it seems to work pretty good. I did have to play with the function that puts the date into the clipboard, but, once I got that working it looks good.
>
>One issue... If the user enters a 4 digit date, it still gets rolled over.
>
>For example, user enters 1/1/1905 it changes to 1/1/2005. Can you think of a way to modify it so that the rollover does not occur if the user enters the full 4 digit date?
>
>Our ap has SET CENTURY ON all the time.
>
>Thanks,
>BOb

Bob, my solution here was to have the dynamic Y2K_ROLLOVER (as Christof suggested in his article ) AND also dynamically changing ROLLOVER
increment value ( I mean + 100 years ), because say, for the birthdays there
is no much sense to add 100 years :). This way ROLLOVER may be set individually for any field.

*************************************************

#DEFINE Y2K_ROLLOVER GetRollOvr() && Was 1950 before

************************
FUNCTION GetRollOvr

* Dynamic Rollover increment value
PUBLIC Incr_Value && declared here because many screens in FPW 2.6 apps
issue CLEAR ALL
Incr_Value = 1200 && default value 1200 month = 100 years.

lcVar = Y2K_Var()

DO CASE
CASE lcVar = "M.LBIRTHDATE" && Field source which needs different
Rollover value
Incr_Value = 0 && If Incr_Value = 0 , nRollOver doesn't matter
because
it will not increment the date at all.
nRollOver = 1870 && For field which handles date of birth

CASE lcVar = "M.LDATEBUILT" && Field source which needs different
Rollover value
Incr_Value = 1200
nRollOver = 1920 && For field which handles date house was built

OTHERWISE
Incr_Value = 1200
nRollOver = 1950 && Default Rollover for all other fields.
ENDCASE

RETURN nRollOver
************************

************** Y2K_Valid1
***********************************************************************

*==================================================
* Valid method to recognize the global flag and
* change the date.
*==================================================
FUNCTION Y2K_Valid1
PARAMETER tuReturn

PRIVATE luReturn
IF PARAMETERS() == 0
luReturn = .T.
ELSE
luReturn = tuReturn
ENDIF

*------------------------
* change date
PRIVATE lcVar
SET CONFIRM &gcY2KConfirm
lcVar = Y2K_Var()
IF glY2K
IF Y2K_MemVar(lcVar)
STORE Y2K_022900() TO (lcVar)
ELSE
REPLACE NEXT 1 ;
(lcVar) WITH Y2K_022900()
ENDIF
SHOW GET (lcVar)
ENDIF
ldDate = EVALUATE(lcVar)
IF YEAR( ldDate ) < Y2K_ROLLOVER
IF Y2K_MemVar(lcVar)
******************* Nick changed*********************************
STORE GOMONTH(ldDate,Incr_Value) TO (lcVar)
*****************************************************************
ELSE
REPLACE NEXT 1 ;
(lcVar) WITH GOMONTH(ldDate,Incr_Value)
ENDIF
ENDIF

*------------------------
* Should we check for a changed field in BROWSE?
********************************************************
IF TYPE( "luReturn" ) == "C"
luReturn = .T.
IF EVALUATE(lcVar) # gdY2KOldVal ;
AND NOT EMPTY(luReturn)
luReturn = EVALUATE(luReturn)
ENDIF
ENDIF
*********************************************************

=Y2K_Failed( luReturn )
RETURN luReturn
*********************** end of Y2K_Valid1************

HTH,

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform