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!

Script Runs Forever . . ?

Status
Not open for further replies.

Rickinrsm

Technical User
Nov 3, 2004
130
US
This script works when I step through it in degubbing modw but when I run it it continues forwvwe abd I have to Ctrl Alt Del to stop it.

Any Ideas?

Code:
method pushButton(var eventInfo Event)
;----------Variables------------------------------
var
Roster	database
Office 	database
tc		Tcursor
tc2		tcursor
i		longInt
endvar
;----------endVariables---------------------------
addAlias("MYDIR","Standard","D:\\PDOXWIN7\\Moore")
	 If not tc.open(":MYDIR:Roster1") then
		errorShow()
		Return
		Endif
		;--------------------------------------
		;Assign Variables from imported table
		;--------------------------------------
    While True
		ID=	(tc."Office Id")
		name=	(tc."Office Name")
            Pho=  (tc."Phone")
		tc.NextRecord()
		Address=		(tc."Office Name")
		tc.NextRecord()
		City=			(tc."Office Name")
		tc.NextRecord()
            ;---------------------------------------------
		;ASSIGN VARIABLES TO Moore Office.db.
		;---------------------------------------------
		tc2.open(":MYDIR:Office")
		tc2.end()
		tc2.edit()
		tc2.insertAfterRecord()
		tc2."Office No"=		ID
		tc2."OfficeName"=		Name
		tc2."StreetAddress"=	Address
		tc2."City"=			City
            tc2."Phone"= 		Pho
            tc2.endEdit()
         Message(tc2.recno())
      tc2.close()
    endWhile
endMethod
 
You need to test for tc.eof() (I believe it is) at the VERY least.

Your while loop is forever. So Paradox is doing what you told it to do.

You have to have some condition that says to break out of the while loop.

Otherwise it will process forever.

You are opening tc one time and processing, but opening and closing tc2 every record set.

You don't need to; just do a tc2.unlockrecord() instead of endedit() and close().

You need to explain what the while loop is supposed to do, though.



Tony McGuire
"It's not about having enough time. It's about priorities.
 
That's right!

The answer is:

if tc.atLast() then
Quitloop
EndIf

Works perfectly Tony.

Thanks much for pointing me in the right direction.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top