*to use this program, have grain1.dbf with alias grain; prices.dbf *with alias prices; and summary.dbf with alias summary all in use * select 1 use grain1 alias grain select 2 use prices select 3 use summary set talk off set procedure to stockpro.prg *first collect the prices we want to use *the prices dbf should be organized so that each record is *a set of prices to use in valueing holdings * *initialize price vector store 0.00 to mpguinea,mpmillet,mpmaize,mpbeans store 0.00 to mpfertiliz,mprice,mpground,mptomato select prices store 0 to mrecord clear @ 5,1 say "Which record of the PRICES database should we use?" @ 7,25 get mrecord read go mrecord *read in relevent prices mpguinea=pguinea mpmillet=pmillet mpmaize=pmaize mpbeans=pbeans mpfertiliz=pfertiliz mprice=price mpground=pgroundnut mptomato=ptomato *now initialize memory variables, and select the grain dbf select grain go top store space(15) to mitem,mform,munit store 0.00 to mvalue store 0.0 to mquantity *now begin the main loop do while .not. eof() mvillage=village mhhnum=hhnum mcash=0.00 && value of household's cash mgrain=0.00 && value of household's stock of grain do while hhnum=mhhnum && loops once for each item madd=0.00 && value of this item mtcash=0.00 mitem=item mform=form mquantity=quantity munit=unit mvalue=value do case case mitem='guinea corn' if mform='threshed'.or.mform='seed' if unit='tiya' madd=mquantity*mpguinea endif if unit='bag' madd=mquantity*40*mpguinea endif else do other endif case mitem='millet' if mform='threshed'.or.mform='seed' if unit='tiya' madd=mquantity*mpmillet endif if unit='bag' madd=mquantity*40*mpmillet endif else do other endif case mitem='maize' if mform='threshed'.or.mform='seed' if unit='tiya' madd=mquantity*mpmaize endif if unit='bag' madd=mquantity*40*mpmaize endif else do other endif case mitem='bean' if mform='threshed'.or.mform='seed'.or.mform=' ' if unit='tiya' madd=mquantity*mpbeans endif if unit='bag' madd=mquantity*40*mpbeans endif else do other endif case mitem='rice' if mform='threshed'.or.mform='seed' if unit='tiya' madd=mquantity*mprice endif if unit='bag' madd=mquantity*40*mprice endif else do other endif case mitem='tomato' if mform<>'seed' if unit='basket' madd=mquantity*mptomato endif if unit='tiya' madd=mquantity*mptomato/15 endif else do other endif case mitem='sorghum' if mform='threshed'.or.mform='seed' if unit='tiya' madd=mquantity*mpguinea endif if unit='bag' madd=mquantity*40*mpguinea endif else do other endif case mitem='fertilizer' if mform<>'refuse' madd=mquantity*mpfertiliz else do other endif case mitem='groundnut' if mform='in shell'.or.mform='seed' if unit='tiya' madd=mquantity*mprice endif if unit='bag' madd=mquantity*40*mprice endif else do other endif case mitem='money' mtcash=mvalue case mitem=' ' madd=outsize-((timeout*insize)/(timein+1)) if madd>0 else madd=0.00 @ 0, 0 say 'mistake in adashi for' @ 0, 21 say mvillage + ' '+ltrim(str(mhhnum)) endif otherwise do other endcase mgrain=mgrain+madd mcash=mcash+mtcash skip enddo *now we're completed with the houshold. Print out results and *add to the summary database clear @ 1, 0 say 'For household '+ltrim(str(mhhnum))+' in '+mvillage @ 3, 0 say 'total cash holdings are ' @ 3, 25 say mcash @ 5, 0 say 'and total grain and adashi holdings are ' @ 5, 40 say mgrain select summary locate for village=mvillage.and.hhnum=mhhnum replace cash with mcash replace grain with mgrain select grain enddo &&now go back up to the next household set talk on