Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Did anybody meet this bug?
Message
From
23/10/2002 10:00:39
 
 
To
23/10/2002 09:03:40
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00714296
Message ID:
00714351
Views:
17
>>Hi all,
>>command LOCATE called on indexed table within class method, where class property is in FOR clause, cause error "Variable ... is not found".
>>Is this problem anywhere reported?
>>Jiri
>>
>>*--------------------------------------------------------
>>Code sample:
>>*----------------------------
>>CLOSE ALL
>>CLEAR ALL
>>CREATE TABLE Tab1 (Field1 C(3))
>>INDEX ON Field1 TAG Field1
>>INSERT INTO Tab1 VALUES("ABC")
>>INSERT INTO Tab1 VALUES("123")
>>INSERT INTO Tab1 VALUES("XYZ")
>>USE
>>
>>o = CREATEOBJECT("cTest", "TAB1.DBF")
>>? o.Find("123")
>>
>>*----------------------------
>>DEFINE CLASS cTest AS Custom
>>cField1 = SPACE(3)
>>cDBF = ""
>>PROCEDURE Init
>>	LPARAMETERS tcDBF
>>	THIS.cDBF = tcDBF
>>ENDPROC
>>PROCEDURE Find
>>	LPARAMETERS tcValue
>>	USE (THIS.cDBF) ALIAS aTab
>>	THIS.cField1 = tcValue		
>>	LOCATE FOR Field1 = THIS.cField1
>>	WITH THIS
>>		WAIT WINDOW ".cField1 = '" + .cField1 + "'"
>>		*---- next command cause error "Variable 'CFIELD1' is not found"
>>		LOCATE FOR aTab.Field1 = .cField1
>>		*---- next two commands resolve this problem
>>		* LOCATE FOR aTab.Field1 = THIS.cField1
>>		* LOCATE FOR aTab.Field1 = .cField1 NOOPTIMIZE
>>		RETURN FOUND()
>>	ENDWITH
>>	USE
>>ENDPROC
>>ENDDEFINE
>>*----------------------------
>
>Please use the HTML code < PRE > to make your code more readable.
>
>Quickly glancing at your code, I see two problems here. First, FIND is a VFP keyword - you should not name your objects using reserved keywords. Second, the USE at the end is never reached - your function returns before this.
>
>Hilmar.


OK, I write the code quickly, only for demonstration.
If you rename the method "Find" to any other name and move the command "USE" closely behind LOCATE command, you receive the same effect: VFP error 12, "Variable 'CFIELD1' is not found".
Jiri
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform