I have a problem using the do while command. In fact, I have a table
(magazines.dbf) that consists of 900.000 records, each representing
sales figures of a magazine. There are 800 different magazines in the
table. Each record has a unique (numeric key - magnumber) that serves
as a proxy for the name of a magazine (numbers start from 100 through
900). What I want to do, is to add records from a given magazine to
another table (report.dbf), and run a program (retail.prg) and repeat
this until the final number of 900 is reached.

I tried this :

cnt=100
do while cnt <= 900
use report
delete all
pack
append from magazines for manumber=cnt
do retail.prg
cnt=cnt+1
enddo

The report is provided for the records with magnumber=100 but at the
line "cnt=cnt+1" I receive the message "variable CNT is not found".

Can you tell me what to do ?



--
blomme
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Re: use of "do while" in Visual foxpro 6 by Gene

Gene
Wed Jan 10 20:22:06 CST 2007

blomme <blomme.2k80xw@mail.codecomments.com> wrote:

>I have a problem using the do while command. In fact, I have a table
>(magazines.dbf) that consists of 900.000 records, each representing
>sales figures of a magazine. There are 800 different magazines in the
>table. Each record has a unique (numeric key - magnumber) that serves
>as a proxy for the name of a magazine (numbers start from 100 through
>900). What I want to do, is to add records from a given magazine to
>another table (report.dbf), and run a program (retail.prg) and repeat
>this until the final number of 900 is reached.
>
>I tried this :
>
>cnt=100
>do while cnt <= 900
>use report
>delete all
>pack
>append from magazines for manumber=cnt
>do retail.prg
>cnt=cnt+1
>enddo
>
>The report is provided for the records with magnumber=100 but at the
>line "cnt=cnt+1" I receive the message "variable CNT is not found".
>
>Can you tell me what to do ?

I would check retail.prg to see if it has any commands that
release variables. For example, clear all would release cnt (and
others).

Instead of delete all / pack, have a look at zap. It is faster.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Re: use of "do while" in Visual foxpro 6 by TonySper

TonySper
Wed Jan 10 21:49:09 CST 2007

I believe that you need to use report excl before you can pack. Use
zap and you do not have to delete the records. Check into your program
to see what is clearing your cnt variable. Are you closing the
database in the retail.prg, if not the do while will error when you
try to use the report again.
TonySper

"blomme" <blomme.2k80xw@mail.codecomments.com> wrote in message
news:blomme.2k80xw@mail.codecomments.com...

I have a problem using the do while command. In fact, I have a table
(magazines.dbf) that consists of 900.000 records, each representing
sales figures of a magazine. There are 800 different magazines in the
table. Each record has a unique (numeric key - magnumber) that serves
as a proxy for the name of a magazine (numbers start from 100 through
900). What I want to do, is to add records from a given magazine to
another table (report.dbf), and run a program (retail.prg) and repeat
this until the final number of 900 is reached.

I tried this :

cnt=100
do while cnt <= 900
use report
delete all
pack
append from magazines for manumber=cnt
do retail.prg
cnt=cnt+1
enddo

The report is provided for the records with magnumber=100 but at the
line "cnt=cnt+1" I receive the message "variable CNT is not found".

Can you tell me what to do ?



--
blomme
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------



Re: use of "do while" in Visual foxpro 6 by Man-wai

Man-wai
Thu Jan 11 06:11:47 CST 2007

private cnt

> cnt=100
> do while cnt <= 900
> use report
> delete all
> pack
> append from magazines for manumber=cnt
> do retail.prg

what does retail.prg do? any reference to "cnt"? If yes,
LOCAL cnt in retail.prg.

> cnt=cnt+1
> enddo

--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10) Linux 2.6.19.1
^ ^ 20:09:02 up 30 days 2:21 0 users load average: 4.10 4.30 4.10
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

Re: use of "do while" in Visual foxpro 6 by Bernhard

Bernhard
Thu Jan 11 10:33:55 CST 2007

Hi Mohammed,

> 799 times (900-100-1).... I need to get back to math 101
If you want to be exact, then it is 801 times.
The first is cnt 100
the second is cnt 101
the third is cnt 102
...
the 801st is cnt 900

Regards
Bernhard Sander

Re: use of "do while" in Visual foxpro 6 by Paul

Paul
Thu Jan 11 13:11:41 CST 2007


LOCAL i
FOR i = 100 TO 900
SELECT * FROM magazines WHERE manumber = m.i INTO CURSOR report
DO retail.prg
ENDFOR
USE IN report

Or better yet, change your report to group by manumber and just run it once.



"blomme" <blomme.2k80xw@mail.codecomments.com> wrote in message
news:blomme.2k80xw@mail.codecomments.com...
>
> I have a problem using the do while command. In fact, I have a table
> (magazines.dbf) that consists of 900.000 records, each representing
> sales figures of a magazine. There are 800 different magazines in the
> table. Each record has a unique (numeric key - magnumber) that serves
> as a proxy for the name of a magazine (numbers start from 100 through
> 900). What I want to do, is to add records from a given magazine to
> another table (report.dbf), and run a program (retail.prg) and repeat
> this until the final number of 900 is reached.
>
> I tried this :
>
> cnt=100
> do while cnt <= 900
> use report
> delete all
> pack
> append from magazines for manumber=cnt
> do retail.prg
> cnt=cnt+1
> enddo
>
> The report is provided for the records with magnumber=100 but at the
> line "cnt=cnt+1" I receive the message "variable CNT is not found".
>
> Can you tell me what to do ?
>
>
>
> --
> blomme
> ------------------------------------------------------------------------
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------
>



Re: use of "do while" in Visual foxpro 6 by KenMurphy

KenMurphy
Tue Jan 30 06:30:35 CST 2007


blomme wrote:
> *I have a problem using the do while command. In fact, I have a
> table (magazines.dbf) that consists of 900.000 records, each
> representing sales figures of a magazine. There are 800 different
> magazines in the table. Each record has a unique (numeric key -
> magnumber) that serves as a proxy for the name of a magazine (numbers
> start from 100 through 900). What I want to do, is to add records
> from a given magazine to another table (report.dbf), and run a program
> (retail.prg) and repeat this until the final number of 900 is
> reached.
>
> I tried this :
>
> cnt=100
> do while cnt <= 900
> use report
> delete all
> pack
> append from magazines for manumber=cnt
> do retail.prg
> cnt=cnt+1
> enddo
>
> The report is provided for the records with magnumber=100 but at the
> line "cnt=cnt+1" I receive the message "variable CNT is not found".
>
> Can you tell me what to do ? *

You can do this in a much simpler way.

SELECT DISTINCT MaNumber FROM Magazines ;
WHERE llSomeCondition
INTO CURSOR MaNos
SCAN
SELECT * FROM Magazines ;
WHERE Magazines.MaNumber = MaNos.MaNumber ;
INTO CURSOR RptCursor
DO Retail.Prg
SELECT MaNos
ENDSCAN

The first SELECT will give you a list of MaNumbers. With your DO WHILE
loop, you could run across a MaNumber that does not have any data. The
SCAN will just loop through the MaNos cursor. The second SELECT
statement will select all of the records from Magazines for each
MaNumber in turn. You run your Retail program and then go back and
cycle through the next loop.

A couple of things to note: Do not use "report" as a cursor or table
name. REPORT is a vfp reserved word (as in REPORT FORM.) Secondly, use
cursors instead of tables where ever you need a temporary table.
Firstly, you do not have to create the table and specify field types and
sizes. The SELECT statement will do that for you. Secondly, you will
eventually have to clean up these temporary tables. If you use a
cursor, VFP will do this for you.



--
KenMurphy
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------