Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LOCATE and SET EXACT
Message
From
22/09/2003 18:21:51
 
 
To
22/09/2003 18:19:43
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00831267
Message ID:
00831280
Views:
17
>Well, Fred, for the same reason that the SCAN 'finds' "XXXXXXXXXX" records even though the field is "XXXXXXXXXX ".
>
>And I figured I'd have to code either SET EXACT ON or use the '==' operator to get the result obtained.
>
>Given that info, what else am I missing?
>

No, the SCAN finds the value because you're comparing the shorter string to the longer string (shorter on the right side of the "="). The LOCATE is doing it with the longer string on the right side.


>
>>Why do you think the first one should work? You're looking for:
>>
>>t2.fld1      t1.flda
>>"XXXXXXXXXX"="XXXXXXXXXX  "
>>
>>
>>>In the following code sample the top LOCATE doesn't find the record yet when the value is ALLTRIMed, as in the second LOCATE, it does.
>>>
>>>Am I missing something here or is this a bug?
>>>SET EXACT OFF
>>>
>>>CREATE CURSOR t1 (Flda C(12), Fldb C(5))
>>>INSERT INTO t1 (Flda, Fldb) VALUES ("XXXXXXXXXX  ", "YYYYY")
>>>INSERT INTO t1 (Flda, Fldb) VALUES ("YYYYYYYYYY  ", "ZZZZZ")
>>>INSERT INTO t1 (Flda, Fldb) VALUES ("XXXXXXXXXX  ", "AAAAA")
>>>
>>>CREATE CURSOR t2 (Fld1 C(10), Fld2 C(5))
>>>INSERT INTO t2 (Fld1, Fld2) VALUES ("XXXXXXXXXX", "YYYYY")
>>>INSERT INTO t2 (Fld1, Fld2) VALUES ("YYYYYYYYYY", "ZZZZZ")
>>>
>>>SELECT t1
>>>GO TOP
>>>SCAN FOR Flda = "XXXXXXXXXX"              && finds this OK
>>>    SELECT t2
>>>    LOCATE FOR Fld1 = t1.Flda             && doesn't find t2 rec 1. Shouldn't it?
>>>    IF FOUND()                            && ...for either t1 rec 1 and t1 rec 3
>>>      WAIT WINDOW "It was found!!!"
>>>    ELSE
>>>      WAIT WINDOW "NOT found!?!?"
>>>    ENDIF
>>>    LOCATE FOR Fld1 = ALLTRIM(t1.Flda )   && now finds t2 rec 1, as expected, for both
>>>    IF FOUND()
>>>      WAIT WINDOW "It was found when ALLTRIMed!!!"
>>>    ELSE
>>>      WAIT WINDOW "NOT found!?!?"
>>>    ENDIF
>>>ENDSCAN
>>>
>>>cheers
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform