Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help on LOCATE() Function
Message
 
 
À
06/07/2013 13:29:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01577863
Message ID:
01577901
Vues:
53
>Sorry, I didn't got that. Can you please give the specific code.
>
>
>
>>>I have around 1000 Records in a file. The file has a field PS, In certain records I have a text 'T M' in the middle and the last three words are 'g n'.
>>>
>>>Using the following function I am able to locate the PS having 'T M' and 'g n' at the last three digits. But the problem is my below mentioned code locates the first instance of T M and g n , while I need the record number of the last occourance of T M and g n.
>>>
>>>I.e I mean to say that I need the last record number whic has the above text.
>>>
>>>Is there any way that locate function finds from bottom to top or any other way
>>>
>>>Here is my code
>>>
>>>
>>>
>>>LOCATE FOR AT('T  M',PS)>0 AND RIGHT(ALLTRIM(Ps),3)='g n'
>>>IF FOUND
>>>lrecordno=RECNO()
>>>ENDIF
>>>
>>>
>>
>>Instead of LOCATE you may try using SELECT statement with TOP 1 AND ORDER BY clause to order the way you want.
SELECT TOP 1 * FROM MyTable WHERE PS LIKE '% T M%' AND RIGHT(ALLTRIM(Ps),3) = 'g n'
ORDER BY IdColumn DESC
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform