Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fox Pro 2.6 for DOS
Message
 
 
À
22/05/1998 23:15:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00101355
Message ID:
00101641
Vues:
27
>Could someone please tell me the difficulties in converting a FoxPro 2.6 for DOS version so that it's Y2K compatible? What code has to be included? Etc.
>
>Thanks

I wrote these two procedures to deal with the y2k problem with FPD2.6.
They do the trick for me. I hope you can use them.

The when clause calls the procedure centwhen.prg which converts the entered
date to a character so that any date could be entered. If this is not done,
there is a problem entering February dates during leap years.

The valid clause then calls the cent_fix.prg procedure which processes the
entered date to make it either 1900 or 2000. The year below which the date
is converted to 2000 can be changed by changing the "pivot_date" variable
in cent_fix.prg

All lines of code which get dates should be changed as below:
Old code:
@ 10, 35 get mvar && mvar being a date variable

New code
@ 10,35 get mvar picture "99/99/99" when centwhen(@mvar);
valid cent_fix(@mvar)
or to have date boundaries use two additional parameters
the range clause does not work with these functions
@ 10,35 get mvar picture "99/99/99" when centwhen(@mvar);
valid cent_fix(@mvar, date() - 30, date() + 30)

-------

*Testdate.prg
set talk off
set bell off
mvar = {}
clear
@ 10,35 get mvar picture "99/99/99" when centwhen(@mvar) valid cent_fix(@mvar) && can havevalid clause also
* With early and late date ranges below
*@ 10,35 get mvar picture "99/99/99" when centwhen(@mvar) valid cent_fix(@mvar, date() - 30, date() + 30) && can havevalid clause also
read
*Show the date with four digit year
set cent on
@ 12,35 say mvar
@ 13,35 say cdow(mvar)
set cent off
return
----------

*centwhen.prg
*Spencer Fried
****
**** Called by the get when clause as part of y2k fixup
**** Converts the date variable to a character variable
**** before it is acted upon. In this way, any date can
**** be entered (including Feb 29 in a non-leap year
**** The valid clause (cent_fix) then does validation and then
**** changes it back to a date variable
**** Returning .t. allows the variable to be edited
****
**** Syntax: @ 2,2 get picture "99/99/99";
**** when centwhen(@) valid cent_fix(@)

parameters x_date
x_date = dtoc(x_date)
return .t.
-----------

*CENT_FIX.PRG - first attempt to deal with millenium problem
*Spencer Fried
****************************************************************
**** cent_fix.prg ****
**** Either 1 or 3 paramaters passed ****
**** SYNTAX @ 12,22 say "Enter Date " get x_date picture "99/99/99";
**** when bbb(@x_date) valid cent_fix(@x_date)
****
**** SYNTAX @ 12,22 say "Enter Date " get x_date picture "99/99/99";
**** when bbb(@x_date) valid cent_fix(@x_date, ,
****
**** if 3 parameters , , ****
**** if 3 parameters the date is changed to either ****
**** the low or hi range if not between them ****
**** Error Checking is done for illegal dates ****
**** ****
**** ****
****************************************************************
*procedure cent_fix
*Assign date to variable
parameters cur_date, range_low, range_hi
*pivot_date is date below which (or equal to)... century is 2000
pivot_date = 10
*Assign century info to variables
rchr_cent = right(cur_date,2) && right two characters of above
lchr_date = left(cur_date,6) && left 6 chrs of date (with set cent off)
*Now calculations
if val(rchr_cent) <= pivot_date
cnew_cent = "20"+rchr_cent
cnew_date = lchr_date + cnew_cent
else
cnew_date = cur_date
endif
*convert cnew_date to date
new_date = ctod(cnew_date)
*Check for illegal dates (when ctod gives illegal date, { / / } is returned
if new_date = { / / } && this is returned if ctod is illegal date
wait window "Illegal Date" nowait
return 0 && returning zero, places cursor in get field again
endif


** Now range checking code (dates were passed from calling program)
if parameters() > 1 && then the range_low and range_hi were passed
if new_date < range_low
wait window "Too Early - Fixed" timeout 2
new_date = range_low
endif
if new_date > range_hi
wait window "Too Late - Fixed" timeout 2
new_date = range_hi
endif
endif
cur_date = new_date
return

**Spencer Fried
**sfried3@ix.netcom.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform