Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP6 DO WHILE problem 1

Status
Not open for further replies.

webmonger

Programmer
Mar 13, 2004
66
AU
In the following code a MSWord document is created and written to in the do_wordinner routine. The code as it stands does not honour the loop command and if say I had 50 items to add to the document and am doing them 10 at a time only the first document with the first 10 items are processed. It then bypasses the LOOP command for the other documents to be created for the rest of the items.
mywordsplitamount = number of items wanted in each document
mywordsplitstart = starting number of the first record of with the item

Code:
DO WHILE  mywordsplitstart < = mywordsplitamount
	SET MESSAGE TO ' Creating WORD document'
	SELECT TEMP_9
	SET FILTER TO
	DO do_wordinner
	mywordsplitstart = mywordsplitstart + mywordsplitamount
	SELECT TEMP_9
	SET FILTER TO
	LOOP
ENDDO

in do_wordinner I set a filter around the mywordsplitstart and mywordsplitamount variables.

Anyone any thoughts?

Bryan
 
Bryan,

It appears you may need another loop to control the groups. This could be accomplished with a FOR or DOWHILE Loop.

Without knowing how you determine the groups - Here is a rough example.

Code:
lnNumberOfGroups
FOR lni = 1 TO lnNumberOfGroups
	DO case
	CASE lni = 1
		mywordsplitstart = 1
		mywordsplitamount = 10
	CASE lni = 1
		mywordsplitstart = 11
		mywordsplitamount = 10
	CASE lni = 1
		mywordsplitstart = 21
		mywordsplitamount = 10
	ENDCASE		
		
	DO WHILE  mywordsplitstart < = mywordsplitamount
	    SET MESSAGE TO ' Creating WORD document'
	    SELECT TEMP_9
	    SET FILTER TO
	    DO do_wordinner
	    mywordsplitstart = mywordsplitstart + mywordsplitamount
	    SELECT TEMP_9
	    SET FILTER TO
	    LOOP
	ENDDO
ENDFOR

Jim Osieczonek
Delta Business Group, LLC
 
I forgot to assign a value to lnNumberOfGroups.

* first line of code should be
lnNumberOfGroups = 3

Jim Osieczonek
Delta Business Group, LLC
 
JIM

Appreciate your suggestion.

However,

The split value is a selectable variable and the number of items is variable ( up to a large number).

The purpose of the routine is to get around a MSWord restriction.

Each item has an image. The image size is variable.

When an internal limit in MSWord is reached the images become place holders only.

When that happens the user will be able to select a lesser number of items in the document.

Thus I feel I cannot hard code a DO CASE statement with a fixed number of CASEs

Thanks

Bryan
 
Your calling program needs to determine the number of groups, and entries in each group. Load them into an array and process them that way.

For example, lets assume your calling program has determined there are 3 groups at:

Group 1 - starting is 1, ending is 8
Group 2 - starting is 9, ending is 18
Group 3 - starting is 19, ending is 24

Load the items into an array. I am hardcoding because I do not have the code you are using to determine the groups, sizes, etc.

Code:
lnNumberOfGroups = 3
DECLARE laTest[lnNumberOfGroups,2]
laTest[1,1] = 1
laTest[1,2] = 8
laTest[2,1] = 9
laTest[2,2] = 18
laTest[3,1] = 19
laTest[3,2] = 24

FOR lni = 1 TO ALEN(latest,1)
    mywordsplitstart = laTest[lni,1]
	mywordsplitamount = laTest[lni,2]
        
    DO WHILE  mywordsplitstart < = mywordsplitamount
        SET MESSAGE TO ' Creating WORD document'
        SELECT TEMP_9
        SET FILTER TO
        DO do_wordinner
        mywordsplitstart = mywordsplitstart + mywordsplitamount
        SELECT TEMP_9
        SET FILTER TO
        LOOP
    ENDDO
ENDFOR


Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top