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

inexplicably skipping mid loop

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
I've got an old procedure I'm modifying to better handle non-numeric issues, some of my changes didn't seem to take affect, so I added a couple of messageboxes and found that it is skipping in the middle.. and I can't explain it:

Code:
Do While nCounter <= 2
	Select IDTable
	cBuffer = 	Alltr(Str ( (IDTable->&cWhatRef + 1), 12,0))
	If nLen < Len(cBuffer ) OR ALLTRIM(CHRTRAN(IDTable->&cWhatRef,"0123456789",""))!=""
		MESSAGEBOX("Found Bad ID",0,"cwhatref")
		Do Case
		
					
               	Case Upper(cWhatRef)="CUSTNO"       
                    	cWhat = "Customer "
			SELECT MAX(cust_num) as iNum							;
                    	FROM (												;
                    		SELECT cust_num 										;
                    		FROM cust) A 											;
                    	WHERE cust_num < replicate("9", nLen) 								;
                    		AND ALLTRIM(CHRTRAN(cust_NUM,"0123456789",""))==""						;
                    	INTO CURSOR curNewNum
               
               	Case Upper(cWhatRef)="CUSPO_NO"      && Purchase Order
               		cWhat = "Purchase Order "
                	SELECT MAX(PO_NUM) as iNum										;
                    	FROM (												;
                    		SELECT PO_NUM 											;
                    		FROM PURCH_TO 											;
                    		UNION 												;
                    		SELECT PO_NUM 											;
                    		FROM POTOP_HI) A 										;
                    	WHERE PO_NUM < replicate("9", nLen) 								;
                    		AND ALLTRIM(CHRTRAN(PO_NUM,"0123456789",""))==""						;
                    	INTO CURSOR curNewNum

		Otherwise	
			cWhat = cWhatRef
		Endcase
***************************************************************************
MESSAGEBOX("I see this messagebox",0,"")
MESSAGEBOX("But not this messagebox or anything after this",0,"")  
***************************************************************************

		MESSAGEBOX("IDTable currently shows " + IDTable->&cWhatRef + " replacing with " + STR(curNewNum.iNum,6,0),0,"trying")
        	Replace IDTable->&cWhatRef With curNewNum.iNum   && this isn't working...
        	mNextRef = STR(curNewNum.iNum, nLen)         	
	Endif
	Replace IDTable->&cWhatRef With IDTable->&cWhatRef + 1

	Select _master  &&  (cMaster)
	Seek mNextRef
     	If Found()
          	If .T.  
               		Fox_Use("werror")
               		Insert Into werror (Time, Date, Version, clerk, stationid, Descriptio, called) ;
                    		VALUES (Time(), Date(), zVerWin, mClerk, mccTID, ;
                    		"GetNxRef found that " + Upper(cWhatRef) + " " + mNextRef + " already exists!", ;
                    		"GetNxRef found #" + mNextRef + "!")
               		Use In werror
               		Select _master
    		Endif
        	nCounter = nCounter + 1           
     	Else
          	Exit
     	Endif
Enddo

Any ideas?

Thanks
-Stephen
 
It looks like I was working off of a different build than I thought I was.. so my messagebox 'skip' is not a real symptom.

The actual issue was that I just misidentified the datatype of curNewNum.iNum.
Can I not edit/erase the original message on TekTips?
 
Can I not edit/erase the original message on TekTips?

You can use the Red Flag link to leave a message for the forum moderator and tell them that, while it is not a 'Red Flag', you are requesting that some attention be taken with the posting.

Good Luck,
JRB-Bldr

 
Stephen,

The fact that you posted a follow-up message to say that the problem no longer exists should be good enough. It's not as if anyone will spend any time trying to figure out the solution, given you have made it clear that that there is no problem any more.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top