Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Correct Syntax For 'AND' & 'OR' with Locate Command
Message
From
25/03/2018 18:20:59
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
25/03/2018 16:26:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01658981
Message ID:
01658984
Views:
66
>>Since the value of I is 2 initially my cursor should Locate for page 3 initially and each time it should locate the data in Pageno 4 , 5 , 6 etc as the value of I increases by 1 each time.
>>But Every Time cursor is halting on Pageno=2 even though the value if I is increasing to 3,4,5 etc. What is the problem ?

As written, the AND only attaches to the "Itemized Calls" since AND takes priority. Use brackets around the ORs:
LOCATE FOR ( LEFT(STREXTRACT(POS,'(',')'),10)= '- One Time' OR ;
LEFT(STREXTRACT(POS,'(',')'),23)='- Account Level Charges' OR ; 
LEFT(STREXTRACT(POS,'(',')'),23)='Itemized Calls' );
AND Pageno=(I+1)
While you're at it- also consider using INLIST around the second two STREXTRACT() rather than repeating the STREXTRACT().

Finally, since this code effectively does a table scan for each I in your for...next unless you have indexes on all the expressions, then (depending on purpose) you might consider a SQL Select to determine which pageno meet your tests.
select pageno distinct from mytable where  LEFT(STREXTRACT(POS,'(',')'),10)= '- One Time' OR ;
LEFT(STREXTRACT(POS,'(',')'),23) in ('- Account Level Charges','Itemized Calls') where pageno>2 order by pageno into cursor mycursor
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform