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

Can not sum ? Strange!

Status
Not open for further replies.

sarah77

Programmer
Jun 4, 2002
36
0
0
US
In my program (VFP5) I wrote the following statement inside a loop to sum a certain values in one variable called mMONTHLY_REMAIN :

mNET=0
mMONTHLY_REMAIN=0
DO WHILE .....
..
..
..
mNET=(((INT(ROUND((mMAN_MONTH*1.833),15)*1000))/1000)-mMONTHLY_VACATION)
mMONTHLY_REMAIN = mMONTHLY_REMAIN + mNET
..
..
ENDDO

NOTE: mMAN_MONTH always should contains a value >0 and <=1
NOTE: mMONTHLY_VACATION may contains a value >=0

After the loop mMONTHLY_REMAIN contains a zero value despite mNET contains a non zero value. WHY ?

I dont understand why it's happen ????

Thanks for any comments
 
Might sound silly, is the code in your loop actually executing (i.e. is the codition true on the first go).

Regards

Griff
Keep [Smile]ing
 
Have you initialized the variables as Public, Private, or Local used in the loop ? If you have not, try initializing mNet and mMonthly_remain as local.

:->
 
would you please post the actual code!!! it will be better to inspet! Tekno
Wireless Toyz
Ypsilanti, Michigan
 
Here is the code I hope it's clear and readable. I'd like to say that the program is getting inside the loop.
*
mMAN=1.833
mNET=0
mMONTHLY_REMAIN=0
mTOTWT=0
mTOTRT=0
mMONTHLY_V=0
mOK=.F.
mBEFORE_B7=.F.
mSLOT=&quot;IPS401&quot;
mCONT_CODE=&quot;SLBS2&quot;
*
SELECT TIMESHEET
SET ORDER TO SLOT
SEEK(ALLTRIM(AGENTS->SLOT_NO)+LTRIM(AGENTS->CONT_CODE))
DO WHILE ALLTRIM(TIMESHEET->SLOTNO)=mSLOT AND ALLTRIM(TIMESHEET->CONT_CODE)=mCONT_CODE AND EOF()=.F.
DO CASE
CASE val(alltrim(TIMESHEET->SHEETYEAR))>val(ALLTRIM(THISFORM.TXTYEAR.VALUE))
&& this record exceeded the b7 month
exit
CASE val(alltrim(TIMESHEET->SHEETYEAR))=val(ALLTRIM(THISFORM.TXTYEAR.VALUE)) and val(alltrim(TIMESHEET->SHEETMONTH))>val(ALLTRIM(THISFORM.TXTMONTH.VALUE))
&& this record exceeded the b7 month
exit
CASE val(alltrim(TIMESHEET->SHEETYEAR))=val(ALLTRIM(THISFORM.TXTYEAR.VALUE)) and val(alltrim(TIMESHEET->SHEETMONTH))=val(ALLTRIM(THISFORM.TXTMONTH.VALUE))
&& this is exactly B7 month
IF mOK=.F. AND mBEFORE_B7=.T.
mMAN_MONTH=((INT(ROUND((mTOTWT/mTOTRT),15)*1000))/1000)
mNET=(((INT(ROUND((mMAN_MONTH*mMAN),15)*1000))/1000)-mMONTHLY_V)
mMONTHLY_REMAIN=mMONTHLY_REMAIN+mNET
mTOTWT=0
mTOTRT=0
mMONTHLY_V=0
mOK=.T.
ENDIF
mTOTWT = mTOTWT + TIMESHEET->WH
mTOTRT = mTOTRT + TIMESHEET->RH
IF INLIST(ALLTRIM(TIMESHEET->PC),'V')
mMONTHLY_V=mMONTHLY_V+1
ENDIF
OTHERWISE
&& this record is before B7 month
mBEFORE_B7=.T.
IF val(alltrim(TIMESHEET->SHEETYEAR))=val(mSheetYear) and val(alltrim(TIMESHEET->SHEETMONTH))=val(mSheetMonth)
* CALCULATE B7ACQ DEPENDS ON THE NEW RULE MAN-MONTH
mTOTWT = mTOTWT + TIMESHEET->WH
mTOTRT = mTOTRT + TIMESHEET->RH
*
IF INLIST(ALLTRIM(TIMESHEET->PC),'V')
mMONTHLY_V=mMONTHLY_V+1
ENDIF
ELSE
mMAN_MONTH=((INT(ROUND((mTOTWT/mTOTRT),15)*1000))/1000)
mNET=(((INT(ROUND((mMAN_MONTH*mMAN),15)*1000))/1000)-mMONTHLY_V)
mMONTHLY_REMAIN=mMONTHLY_REMAIN+mNET
mTOTWT=0
mTOTRT=0
mMONTHLY_V=0
mSheetMonth=alltrim(TIMESHEET->SHEETMONTH)
mSheetYear=alltrim(TIMESHEET->SHEETYEAR)
mTOTWT = mTOTWT + TIMESHEET->WH
mTOTRT = mTOTRT + TIMESHEET->RH
ENDIF
ENDCASE
SELECT TIMESHEET
SKIP
ENDDO

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top