Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Did anybody meet this bug?
Message
From
23/10/2002 09:03:40
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
23/10/2002 08:37:05
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00714296
Message ID:
00714311
Views:
19
>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.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform