Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LOCATE and SET EXACT
Message
De
22/09/2003 18:25:27
 
 
À
22/09/2003 18:21:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00831267
Message ID:
00831282
Vues:
24
>>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.

It was feeling like stupidity and now it is confirmed!


>
>
>>
>>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform