a scan/end scan question again.

a scan/end scan question again.

Post by VG9t » Fri, 26 Aug 2005 01:46:08


i know im still a rookie, and im getting better. my code is not linking the 2
records in order to replace the correct data from file 2 (lopchk), it must be
simple cause i cant seem to get it.

Close Data
Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
(10,2), ldate d, fretchk n(10,2), fdte d)
Select 0
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
set order to key
SET FILTER TO fulopmas.qdro = "Q"
Select 0
Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
set order to empind
SELECT fulopmas
GO top
Scan
fkey=
PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
Select lopchk
lkey =
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
If Seek (lkey)
if lopchk.checkamt > 0.00
select qdrotest
append blank
replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
fulopmas.dtlstchk
replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
Endif
skip
Select fulopmas
endif
Endscan
 
 
 

a scan/end scan question again.

Post by Jack Jacks » Fri, 26 Aug 2005 02:33:21

On Wed, 24 Aug 2005 09:46:08 -0700, Tom



You set 'fkey' from the current record in fulopmas, then as far as I
can see never use it.

You set 'lkey' from the current record in lopchk, then do a SEEK in
lopchk for 'lkey', which will always find the current record in
lopchk. Do you mean to use 'fkey' in the SEEK()?

What is the purpose of the 'skip' and the 'Select' near the bottom?
When the SKIP is executed, the current alias is either lopchk or
qdrotest, depending on whether or not the SEEK found a match. I don't
see any reason to do a SKIP.

The Select is executed only if the Seek found a match, but the current
work area will be lopchk if it didn't find a match. I don't see any
reason to do a Select.

 
 
 

a scan/end scan question again.

Post by Cindy Wine » Fri, 26 Aug 2005 02:52:42

Hi Tom,

See if this does what you want:


Close Data
Create Cursor qdrotest ;
(agency N (6), dpt N(2), employee N (6), ;
lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
Shared Alias fulopmas Order Key
Use F:\lopfi\dbases\lopchk In 0 ;
Shared Alias lopchk Order EmpInd

Select fulopmas
Scan For fulopmas.qdro = "Q"
fkey= ;
PADL(fulopmas.agency,6,"0")+ ;
PADL(fulopmas.dpt,3,"0")+ ;
PADL(fulopmas.employee,6,"0")
lkey = ;
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
PADL(lopchk.employee,6,"0")+ ;
STR(YEAR(lopchk.checkdte),4,0)+ ;
STR(MONTH(lopchk.checkdte),2,0))

If Seek (lKey, "lopChk", "empind") ;
And lopChk.CheckAmt = 0
Insert Into qdrotest ;
(agency, dpt, employee, fretchk, ;
fdte, lchkamt, ldate) ;
Values ;
(fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
fulopmas.retchkamt, fulopmas.dtlstchk, ;
lopchk.checkamt, lopchk.checkdte)
EndIf
EndScan


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
Blog: http://www.yqcomputer.com/
 
 
 

a scan/end scan question again.

Post by Cindy Wine » Fri, 26 Aug 2005 03:05:20

Hi Tom,

See if this does what you want:


Close Data
Create Cursor qdrotest ;
(agency N (6), dpt N(2), employee N (6), ;
lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
Shared Alias fulopmas Order Key
Use F:\lopfi\dbases\lopchk In 0 ;
Shared Alias lopchk Order EmpInd

Select fulopmas
Scan For fulopmas.qdro = "Q"
fkey= ;
PADL(fulopmas.agency,6,"0")+ ;
PADL(fulopmas.dpt,3,"0")+ ;
PADL(fulopmas.employee,6,"0")
lkey = ;
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
PADL(lopchk.employee,6,"0")+ ;
Left(DtoS(lopchk.checkdte), 6)
*-- Check out DtoS() in Help

If Seek (fKey, "lopChk", "empind") ;
And lopChk.CheckAmt > 0
Insert Into qdrotest ;
(agency, dpt, employee, fretchk, ;
fdte, lchkamt, ldate) ;
Values ;
(fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
fulopmas.retchkamt, fulopmas.dtlstchk, ;
lopchk.checkamt, lopchk.checkdte)
EndIf
EndScan


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
Blog: http://www.yqcomputer.com/
 
 
 

a scan/end scan question again.

Post by Cindy Wine » Fri, 26 Aug 2005 03:06:58

Hi Tom,

(Sorry for previous messages. OE is being flaky.)

See if this does what you want:


Close Data
Create Cursor qdrotest ;
(agency N (6), dpt N(2), employee N (6), ;
lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
Shared Alias fulopmas Order Key
Use F:\lopfi\dbases\lopchk In 0 ;
Shared Alias lopchk Order EmpInd

Select fulopmas
Scan For fulopmas.qdro = "Q"
fkey= ;
PADL(fulopmas.agency,6,"0")+ ;
PADL(fulopmas.dpt,3,"0")+ ;
PADL(fulopmas.employee,6,"0")
lkey = ;
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
PADL(lopchk.employee,6,"0")+ ;
Left(DtoS(lopchk.checkdte), 6)
*-- Check out DtoS() in Help

If Seek (fKey, "lopChk", "empind") ;
And lopChk.CheckAmt > 0
Insert Into qdrotest ;
(agency, dpt, employee, fretchk, ;
fdte, lchkamt, ldate) ;
Values ;
(fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
fulopmas.retchkamt, fulopmas.dtlstchk, ;
lopchk.checkamt, lopchk.checkdte)
EndIf
EndScan


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
Blog: http://www.yqcomputer.com/
 
 
 

a scan/end scan question again.

Post by VG9t » Fri, 26 Aug 2005 03:24:09

indy, i got your first post and tweaked it like your last before you posted,
its worked great.

i cannot thank you enough for your help. do you know of a Good reference
book i could get to give me a highly detailed reference to VFP?

i like this forum, but feel stupid asking basic questions all the time when
i feel i need someone to walk me through it, rather than give the answer.


"Cindy Winegarden" wrote:

 
 
 

a scan/end scan question again.

Post by Dan Freema » Fri, 26 Aug 2005 03:43:40

he best reference to VFP is the Hacker's Guide, which hasn't been updated
since VFP7. It's available from www.hentzenwerke.com, as are a number of
other high-quality books about VFP.

You can fill in the bits added to VFP from the "What's new in..." titles for
VFP8 and VFP9, again from Hentzenwerke.

Dan

Tom wrote:
PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,
6,"0")
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0"
)+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))


 
 
 

a scan/end scan question again.

Post by VG9t » Fri, 26 Aug 2005 03:47:08

Cindy, that works fine with one exception...

it puts 41 records into qdrotest. the problem in Fulopmas has 104.

if i open the tabel and count for qdro= "Q" i get 104 recs.

is there a reason its not picking up those 63 recs?
 
 
 

a scan/end scan question again.

Post by Cindy Wine » Fri, 26 Aug 2005 04:11:57

Hi Tom,

You are only inserting a record when you've found a record in lopChk and
loch.CheckAmt = 0. Does that change anything?


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
Blog: http://www.yqcomputer.com/
 
 
 

a scan/end scan question again.

Post by Cindy Wine » Fri, 26 Aug 2005 04:14:57

Hi Tom,

There's a big difference between a "stupid" person and a person who's just
uninformed and needs to learn. We all, including me, started from knowing
zero at some point in our lives.

I've learned a lot from reading these groups over the years; also,
GoogleGroups (groups.google.com, the archives of these newsgroups) is a
great resource.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
Blog: http://www.yqcomputer.com/
 
 
 

a scan/end scan question again.

Post by Jack Jacks » Fri, 26 Aug 2005 05:05:10

Cindy,

What am I missing here?

'fkey' is set but never used.

'lkey' is set from the current record in lopchk, and is used to Seek
in lopchk. Why doesn't the seek always work?

On Wed, 24 Aug 2005 13:52:42 -0400, "Cindy Winegarden"
 
 
 

a scan/end scan question again.

Post by Cindy Wine » Fri, 26 Aug 2005 07:57:47

What you're missing is my later post where I corrected the code to seek fkey
instead of lkey. I tried to cancel the above message but I guess it didn't
work.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
XXXX@XXXXX.COM www.cindywinegarden.com
Blog: http://www.yqcomputer.com/
 
 
 

a scan/end scan question again.

Post by Olaf Dosch » Sat, 27 Aug 2005 00:44:59

> Select lopchk

I don't think this is what you want.

As you build lkey with values of fields of the active record of lopchk,
the Seek will find this key (assuming the index "empind" is defined with the same
expression) but will simply find the same record you already sit on, won't it?

If there are more records matching that expression you'd always
point to the first of these records after Seek().

I could imagine you wanted to do something like this instead (pseudocode):

select <parent table>
scan
fkey = <some index expression with fields of parent table found as foreign key in child table>
select <child table>
if seek(fkey)
scan rest while fkey = <some expression with fields of the child table>
<do something for all these child table records related to the active record of the parent table>
endscan
endif
endscan

Bye, Olaf.
 
 
 

a scan/end scan question again.

Post by VG9t » Sat, 27 Aug 2005 06:19:04

Thank you all for your advice and patience as i know some of this is "easy"
for you.
i hope to continue to grow and develop skills i pick up on my own as wellas
from groupd like this.

Thanks again.