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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record not iterate as intend

Status
Not open for further replies.

koklimabc

Programmer
Jun 17, 2013
49
MY
Hi all,
I've running this below sample part of coding and tried to append bundle of thousand record from txt file into a tables.
It is all occupied in Foxpro 2.6.
Those record has nothing problem to append full details into tables(vc_tmpdate and recorded 3000's but the loop is only encounter with less than 3000's which means it can be lower than 3000's pcs of records. Can anyone tell me how to fix it.

Coding :

vc_tmpdate = ALLTRIM(sys(3)) + ".DBF"

vc_appfile = "C:\tmp\test.txt"

create (vc_tmpdate) (text c(254))
append from (vc_appfile) type SDF
REPL ALL TEXT WITH ALLTRIM(TEXT)
DELE ALL FOR LEN(ALLTRIM(TEXT)) < 15
PACK
vn_norec = RECCOUNT()
GO TOP
vc_alias = ALIAS()

DO WHILE NOT EOF()

vn_pro = vn_pro + 1
WAIT "Process record -->" + ALLTRIM(STR(vn_pro)) + "/" + ALLTRIM(STR(vn_recno)) WIND NOWAIT
SKIP
ENDDO

I've attach picture for this problem.
 
 http://files.engineering.com/getfile.aspx?folder=7766ecf0-77d5-426d-8eac-d3a1c63a7463&file=samp.jpg
Is this really the code as is? Your total number of records displayed - vn_recno - differs from the reccount you determine a few lines above: vn_norec = RECCOUNT()
You may display some value from any previous code set into the variable vn_recno and still in scope. Besides you never initialize vn_pro to 0.

This speaks for itself, try to use mostly LOCAL variables and you don't have such flaws in your code, they will get apparent, as you then will try to access a non existing variable.

Bye, Olaf.
 
Right Olaf,

vn_recno is not vn_norec

And don't we need a
vn_pro=0
somewhere ?
 
Correct, I edited that to my answer, an initialisation of the vn_pro counter also is needed, it may be somewhere before the shown code.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top