Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why these two commands will give different results
Message
From
06/12/2006 13:29:05
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01174441
Message ID:
01175327
Views:
7
Make a breakpoint when cCinv changes value in the debugger.

>It doesn't make any sense. Where the variable is changing?
>
>
>Found a mismatch on I801972COL  cRate = 0 laArr[1]= 0.100000000 Cnt:1 Fnd:.F.
> Recno: 93204 Inv_No: I801737 Salesman: COL  Rate: 10 Share: 100 Inv_No + Salesman: I801737COL  Variables: I801737COL  LEN(fields): 11 LEN(Vars): 11
>
>
>LOCAL lnRecno, laArr[1]
>local laArrChk[1], lnRun, lnCheck, llSeekfnd, lcMess, cCinv
>lnCheck = 10
>
>SELECT Pay_Item
>DO softseek WITH cpay
>SCAN WHILE pay_no=cpay
>    DO CASE
>        CASE rtv_pay$'IM' .AND. VAL(Pay_Item.inv_no)<960000
>            cCinv=rtv_pay+LTRIM(inv_no)
>            camt=amount
>            IF rtv_pay='I'
>                SELECT invoice
>            ELSE
>                SELECT MEMO
>            ENDIF
>            SEEK Pay_Item.inv_no
>            IF gr_total>0
>                cSnh=cSnh+snh*Pay_Item.amount/gr_total
>                SELECT comision
>                lnRecno = RECNO()
>
>
>SELECT SUM(rate*SHARE/10000) AS crate, count(*) ;
>                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
>              	FROM comision INTO ARRAY laArr
>
>
>As you see, the cCinv variable is declared as local (I just added this declaration) and calculated only once right before the select sum. Why would it change?
>
>Sorry for cc-ing.
>
>>Thomas,
>>
>>Thanks a lot for your help.
>>
>>Here are results:
>>Found a mismatch on I801972COL cRate = 0 laArr[1]= 0.100000000 Cnt:1 Fnd:.F.
>> Recno: 93204 Inv_No: I801737 Salesman: COL Rate: 10 Share: 100 Inv_No + Salesman: I801737COL Variables: I801737COL LEN(fields): 11 LEN(Vars): 11
>>Found a mismatch on I909648COL cRate = 0 laArr[1]= 0.094859333 Cnt:1 Fnd:.F.
>> Recno: 285704 Inv_No: I503576 Salesman: COL Rate: 9.4859333 Share: 100 Inv_No + Salesman: I503576COL Variables: I503576COL LEN(fields): 11 LEN(Vars): 11
>><snip>
>>
>>As you see, somehow we're looking now for a different thing, since Inv_No doesn't match. Somewhere the variable is changing to a wrong var. I should be able to find the problem now, I think.
>>
>>>Naomi,
>>>>I put set order to and got
>>>>
>>>>Found a mismatch on I909648COL cRate = 0 laArr[1]= 0.094859333
>>>...
>>>>Found a mismatch on I518767COL cRate = 0 laArr[1]= 0.100000000
>>>>
>>>>This is strange since these Inv_No + Salesman do not exist in the table. I've tried to do select and seek in command window and they returned empty results.
>>>>
>>>>Somehow SELECT SUM() finds wrong records. I re-built index Com_Inv earlier today by deleting it first.
>>>
>>>I still presume my first guess was correct<g>. To verify (replace file_log with your personal log call):
>>>SELECT Comision
>>>lnRecno = RECNO()  && Dunno what for
>>>
>>>local laArrChk [1], lnRun, lnCheck, llSeekfnd, lcMess
>>>lnCheck = 10
>>>
>>>SELECT SUM(rate*SHARE/10000) AS crate, count(*) ;
>>>                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
>>>              	FROM comision INTO ARRAY laArr
>>>
>>>if laArr[1,2]>0
>>>   if laArr[1,2]<=6000
>>>      SELECT ;
>>>             Recno(), inv_no, salesman, rate, SHARE ;
>>>             , inv_no+salesman, m.ccinv + m.Slsman ;
>>>             , Len(inv_no+salesman), Len(m.ccinv + m.Slsman) ;
>>>                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
>>>              	FROM comision INTO ARRAY laArrChk
>>>     assert _tally=laArr[1,2]
>>>   else
>>>      SELECT top m.lnCheck ;
>>>             Recno(), inv_no, salesman, rate, SHARE ;
>>>             , inv_no+salesman, m.ccinv + m.Slsman ;
>>>             , Len(inv_no+salesman), Len(m.ccinv + m.Slsman) ;
>>>                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
>>>              	FROM comision INTO ARRAY laArrChk
>>>   endif
>>>endif
>>>
>>>SELECT Comision
>>>SET ORDER TO com_inv IN comision
>>>IF SEEK(m.ccinv + m.Slsman)                	
>>>	SUM (rate*SHARE/10000) TO cRate WHILE inv_no+salesman = m.ccinv + m.Slsman
>>>        llSeekfnd = .t.
>>>ELSE
>>>	cRate = 0
>>>endif		
>>>
>>>lcRate = EVL(laArr[1],0)
>>>IF NOT m.cRate = m.lcRate
>>> 	=MESSAGEBOX("Found a mismatch on " + m.ccinv + ":" + m.Slsman)
>>>        lcMess = "Found a mismatch on " + m.ccinv + m.Slsman + " cRate = " + ;
>>>        	TRANSFORM(m.cRate)  + " laArr[1]= " + TRANSFORM(m.lcRate)
>>>	_cliptext = _cliptext + m.lcMess
>>>        =File_Log(m.lcMess ;
>>>                  + " Cnt:" + TRANSFORM(laArr[1,2])
>>>                  + " Fnd:" + TRANSFORM(m.llSeekfnd)
>>>                  + Chr(13)+chr(10))
>>>        for lnRun = 1 to min(alen(laArrChk, 1), m.lnCheck)
>>>           =File_Log(":1:" + Transform(laArrChk[m.lnRun, 1])  ;
>>>                    +":2:" + Transform(laArrChk[m.lnRun, 2])  ;
>>>                    +":3:" + Transform(laArrChk[m.lnRun, 3])  ;
>>>                    +":4:" + Transform(laArrChk[m.lnRun, 4])  ;
>>>                    +":5:" + Transform(laArrChk[m.lnRun, 5])  ;
>>>                    +":6:" + Transform(laArrChk[m.lnRun, 6])  ;
>>>                    +":7:" + Transform(laArrChk[m.lnRun, 7])  ;
>>>                    +":8:" + Transform(laArrChk[m.lnRun, 8])  ;
>>>                    +":9:" + Transform(laArrChk[m.lnRun, 9])  ;
>>>                    +Chr(13)+chr(10))
>>>        next
>>>ENDIF
>>>
>>>regards
>>>
>>>thomas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform