LPARAMETERS tnPageNo *-- Expecting This.cPagesToPrint to contain any of the following: *-- A Numeric Value for an individual page *-- 10 *-- A list of pages to print, separated by ',' or ' ' *-- 1, 5, 7 *-- The list of pages can include a range indicated with a "-" *-- 1, 5, 7-10, 12 *-- The word "odd" or "even" to indicate only odd or even pages *-- If ODD or EVEN is combined with anything else, only do the *-- Odd or Even pages that match the other criteria. LOCAL llPrint, ; lnPages, ; laPages, ; lnRange, ; laRange, ; lnStart, ; lnEnd, ; lnFor, ; lnForPages, ; lcOddEvenAll, ; lcTmp llPrint = .f. lcOddEvenAll = "A" *-- Make it easy to get out FOR lnFor = 1 TO 1 *-- Nothing special to do, just get out and print IF EMPTY(This.cPagesToPrint) llPrint = .t. EXIT ENDIF *-- If numeric, assume this page IF VARTYPE(This.cPagesToPrint) == 'N' llPrint = m.tnPageNo == This.cPagesToPrint EXIT ENDIF *-- Determine whether odd or even has been indicated DO CASE CASE 'ODD' $ UPPER(This.cPagesToPrint) AND ; 'EVEN' $ UPPER(This.cPagesToPrint) lcOddEvenAll = "A" CASE 'ODD' $ UPPER(This.cPagesToPrint) lcOddEvenAll = "O" CASE 'EVEN' $ UPPER(This.cPagesToPrint) lcOddEvenAll = "E" OTHERWISE lcOddEvenAll = "A" ENDCASE *-- If Odd or Even, get out if that's all there is IF NOT m.lcOddEvenAll = "A" lcTmp = UPPER(This.cPagesToPrint) lcTmp = STRTRAN(m.lcTmp, 'ODD', '') lcTmp = STRTRAN(m.lcTmp, 'EVEN', '') lcTmp = ALLTRIM(m.lcTmp, 1,',- ') IF EMPTY(m.lcTmp) llPrint = .t. EXIT ENDIF ENDIF *-- Create an array of pages DIMENSION laPages[1] lnPages = ALINES(m.laPages, This.cPagesToPrint, 1+4, ',', ' ') *-- If nothing was found, get out w/o printing *-- (This can happen if the string just has parse characters) IF m.lnPages = 0 EXIT ENDIF *-- See if this page exists in the array FOR ln = 1 TO m.lnPages *-- Loop if this is the Odd/Even row IF UPPER(m.laPages[m.ln]) = 'ODD' OR UPPER(m.laPages[m.ln]) = 'EVEN' LOOP ENDIF *-- If this row is a range, process accordingly IF '-' $ m.laPages[m.ln] DIMENSION laRange[1] lnRange = ALINES(m.laRange, m.laPages[m.ln], 1+4, '-') *-- There should only be 2 rows (a start and end page) IF m.lnRange <> 2 LOOP ENDIF *-- Get the starting and ending pages lnStart = INT(VAL(m.laRange[1])) lnEnd = INT(VAL(m.laRange[2])) *-- Make sure the starting page is not greater than the ending page IF m.lnStart > m.lnEnd LOOP ENDIF *-- Is this page in this range? IF BETWEEN(m.tnPageNo, m.lnStart, m.lnEnd) m.llPrint = .t. EXIT ENDIF *-- Nothing more to check on this one LOOP ENDIF *-- Is this page listed? lnStart = INT(VAL(m.laPages[m.ln])) IF m.tnPageNo == m.lnStart m.llPrint = .t. EXIT ENDIF ENDFOR ENDFOR *-- Check the Odd/Even page IF (m.lcOddEvenAll = "O" AND MOD(m.tnPageNo,2) = 0) OR ; (m.lcOddEvenAll = "E" AND NOT MOD(m.tnPageNo,2) = 0) m.llPrint = .f. ENDIF RETURN m.llPrint