Hi Michael

I'd use http://fox.wikis.com/wc.dll?Wiki~Weekdays~VFP to compute the
number of weekdays (mon-friday no weekends) instead of looping like
that. Blinding speed.

Then I'd use a UDF to return the number of holidays between the two
dates. The UDF could use a cursor opened at app start and an SQL
command to count the holidays. Just exclude holidays that fall on
weekends from the holidays table.

By the way

http://fox.wikis.com/wc.dll?Wiki~SEEKvsASCAN~DotNet

I don't bother with arrays in VFP much at all.

Then your could would be

REPLACE ;
  nTimeSpent WITH ;
  weekdays(m.ldDate,m.ldDate+m.lnNumDaysFromNow) ;
  - holidays(m.ldDate,m.ldDate+m.lnNumDaysFromNow),;
 dExpected WITH m.ldDate ;
     IN (tcCursor)

You could go crazy and make a workdays function that combined those
two functions too.

HTH

> Message: 3
> Date: Tue, 09 Jan 2007 16:16:04 -0500
> From: MB Software Solutions <[EMAIL PROTECTED]>
> Subject: Re: repetitive SEEKs
> To: [EMAIL PROTECTED]
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii"
>
> MB Software Solutions wrote:
> > Matthew Jarvis wrote:
> >
> >> Since it sounds like Holidays is just a lookup table, why not load it
> >> into an array at app startup?
> >>
> >> Not much diff than a local cursor, but....
> >>
> >>
> >
> > True, and performance-wise I'm sure that'd be quick (if not the
> > quickest!), but alas you've exposed me...I really don't like dealing
> > with arrays as much.  ;-)
> >
> >
> Here's the segment of code in question:
>
>                    lnCtr = lnCtr + EVALUATE(tcCursor +
> ".nEstimatedTime") - EVALUATE(tcCursor + ".nActualTime")
>                    lnNumDaysFromNow = INT(lnCtr / tnMaxHrs)
>                    ldDate = DATE() && starting date
>                    lnLoop = 0
>                    DO WHILE lnLoop <= lnNumDaysFromNow
>                        IF NOT(INLIST(DOW(ldDate),1,6) OR
> SEEK(ldDate,"luHolidays","dDate")) THEN && only count if not a weekend
> and not a holiday
>                            lnLoop = lnLoop + 1
>                        ENDIF
>                        ldDate = ldDate + 1
>                    ENDDO && WHILE lnLoop <= lnNumDaysFromNow
>                    REPLACE nTimeSpent WITH lnCtr, dExpected WITH ldDate ;
>                        IN (tcCursor)
>
>
> --
> Michael J. Babcock, MCP
> MB Software Solutions, LLC
> http://mbsoftwaresolutions.com
> http://fabmate.com
> "Work smarter, not harder, with MBSS custom software solutions!"
>
>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to