Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referencing variable cursor names and their fields
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01515685
Message ID:
01515691
Views:
45
>I just can't get FoxPro to go my way on this, so I must be wrong in my approach. In the following code, I loop through 12 cursors, each representing a month of the year. I then look for a combined key to find a record in another cursor that is indexed, with an INDEX TAG called FULL_KEY (GrpID+PlanKey). In the SEEK() below, this part won't compile, and it is obviously because I am referencing the cursor and its fields incorrectly, as in: IF SEEK((lcCursor).GrpID+(lcCursor).PlanKey, "GrpsPlansCarrs", "Full_Key")
>
>How do you reference a field of a variable cursor name, in the below case?
>
>
>FOR nMonth = 1 TO 12
>	lcMonth = PADL(nMonth, 2, "0")
>	* Get the Carrier ID (Matches GrpID and PlanKey) 
>	* and the Benefit Name (Matches PlanKey).
>	lcCursor=("tmpNearly"+lcMonth)
>	SELECT (lcCursor)
>	SCAN
>		IF SEEK((lcCursor).GrpID+(lcCursor).PlanKey, "GrpsPlansCarrs", "Full_Key")
>			REPLACE (lcCursor).CarrID WITH GrpsPlansCarrs.Carr, ;
>				(lcCursor).Benefit WITH GrpsPlansCarrs.CovDesc8
>		ENDIF
>	ENDSCAN
>ENDFOR
>
>
>Maybe the below might work?
>
>IF SEEK((lcCursor)+".GrpID"+(lcCursor)+".PlanKey", "GrpsPlansCarrs", "Full_Key")
>			REPLACE (lcCursor)+".CarrID" WITH GrpsPlansCarrs.Carr, ;
>				(lcCursor)+".Benefit" WITH GrpsPlansCarrs.CovDesc8
>
FOR nMonth = 1 TO 12
	lcMonth = PADL(nMonth, 2, "0")
	* Get the Carrier ID (Matches GrpID and PlanKey) 
	* and the Benefit Name (Matches PlanKey).
	lcCursor=("tmpNearly"+lcMonth)
	SELECT (lcCursor)
	SCAN
		IF SEEK(&lcCursor..GrpID+&lcCursor..PlanKey, "GrpsPlansCarrs", "Full_Key")
			REPLACE CarrID  WITH GrpsPlansCarrs.Carr, ;
				Benefit WITH GrpsPlansCarrs.CovDesc8 IN (lcCursor)
		ENDIF
	ENDSCAN
ENDFOR
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform