Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New WEEKDAYS function.
Message
De
20/08/2003 14:25:24
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00821896
Message ID:
00821929
Vues:
32
Hi Mark

I know you know I know (or something like that). ;) I did have it broken out, and I covered my (self/butt/whatever) by adding the word "reasonable" to my specifications for number of lines. ;)

At least I formatted it into sections. The first part does the adjustments, the second does the 5/7ths thingy and the third removes the adjustments. It's not too hard to follow, is it?

>I know you were trying to compress the code into as few a lines as possible, but I would split the code in the RETURN into legible lines of code, then have the RETURN return the result.
>
>>I'm interested in any comments that would improve the routine.
>>
>>Here's WEEKDAYS.PRG...
>>
LPARAMETERS tdFrom, tdTo
>>IF VARTYPE(m.tdFrom)#"D" OR VARTYPE(m.tdTo)#"D"
>>  RETURN .F.
>>ENDIF
>>LOCAL ldFrom, ldTo, lnDOWFrom, lnDOWTo
>>ldFrom = MIN(m.tdFrom,m.tdTo)
>>ldTo = MAX(m.tdFrom,m.tdTo)
>>lnDOWFrom = DOW(m.ldFrom,1)
>>lnDOWTo = DOW(m.ldTo,1)
>>RETURN INT(((m.ldTo + IIF(m.lnDOWTo >= 2,7 - m.lnDOWTo,-1));
>>  - (m.ldFrom - IIF(m.lnDOWFrom <= 6,m.lnDOWFrom - 1,0)) + 1) * 5 / 7) ;
>>  - IIF(m.lnDOWFrom >= 2 AND m.lnDOWFrom <= 6,m.lnDOWFrom - 2,0) ;
>>  - IIF(m.lnDOWTo >= 2 AND m.lnDOWTo <= 6,6 - m.lnDOWTo,0)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform