What? Made MY code more readable or YOURS, you cheeky scamp! <bg>
The thing about immediate IIFs is they're fine for, say, expressions in report fields, grids, where you can't put lines of code, but not very readable for complex expressions like these. Good ole If .. Endif is favourite. I don't know if my soln would have worked OK, with the recursion and all, but at least it put you on the right track. Personally, if you've read any of my rants, I'd never use EXIT or LOOP, so my version of yours would have been something like:
Do while not llGotFreePage
the thing also about bracketing your code with "With thisform etc." is
1. things like IIF()s can be more readable
2. VFP doesn't have to keep continuously searching the object hierarchy to find the one to which you're referring
Incidentally, I don't think your function ever WILL return lnNextPage as you use the evil EXIT to get out as soon as you've got a free page.
"Stick with me, kid, and you'll be wearing diamonds"
Terry
>Hi Terry and Jon
>
>Thanks for the code. I have adapted Terry's logic as follows (hopefully made it more readable <g>)
>
>NextButton.Click()
>
DODEFAULT()
>
>THISFORM.pgf.ACTIVEPAGE = THISFORM.GetNextPageNo()
>
>THISFORM.PrevNextCaption()
>
>PreviousButton.Click()
>
DODEFAULT()
>
>THISFORM.pgf.ACTIVEPAGE = THISFORM.GetPreviousPageNo()
>
>THISFORM.PrevNextCaption()
>
>Form.PrevNextCaption()
>
IF TYPE("THISFORM.cmdPrevious.CAPTION") # "C"
> RETURN
>ENDIF
>
>WITH THISFORM
> .cmdPrevious.CAPTION = "<< " + .pgf.PAGES(.GetPreviousPageNo()).CAPTION
> .cmdNext.CAPTION = .pgf.PAGES(.GetNextPageNo()).CAPTION + " >>"
>ENDWITH
>
>Form.GetNextPageNo()
>
LOCAL lnActPage, lnLastPage, lnNextPage
>
>WITH THISFORM
> lnActPage = .pgf.ACTIVEPAGE
> lnLastPage = .pgf.PAGECOUNT
>
> DO WHILE .T.
> lnNextPage = lnActPage + 1
>
> IF lnNextPage > lnLastPage
> lnNextPage = 1
> ENDIF
>
> IF NOT .pgf.PAGES( lnNextPage).ENABLED
> lnActPage = lnNextPage
> ELSE
> EXIT
> ENDIF
> ENDDO
>ENDWITH
>
>RETURN lnNextPage
>
>
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.