Hi,
After some work on older project I've received error message "Syntax error" on line with simple LOCATE command working well for ages there.
During sleepless night I have find out, that there are a few ways to eliminate the problem.
- avoid indexing on field which is LOCATEd (comment out line "INDEX ON category TAG category" to see)
- disable using Rushmore optimization (add NOOPTIMIZE clause to LOCATE or SET OPTIMIZE OFF)
- eliminate use of object property in LOCATE statement (substitute it with standard variable MyVar = M.oUserSel.category)
- use SEEK M.oUserSel.category instead
This still doesn't give me an answer to what's going wrong with my LOCATE statement.
Will someone explain it to me? I smell a rat in Rushmore.
Thank you, Tom (VFP 7, SP1)
After some work on older project I've received error message "Syntax error" on line with simple LOCATE command working well for ages there.
Code:
* This program has no other meaning then to illustrate mentioned syntax error
* It is a fragment of a project, so don't ask why SCATTER, INDEX ON or GO 2 is used here
CREATE table tblPersons (name c(20),category c(10),year c(4))
INSERT INTO tblPersons VALUES ("Paul A. Samuelson","Economics","1970")
INSERT INTO tblPersons VALUES ("John Galsworthy","Literature","1932")
INSERT INTO tblPersons VALUES ("Winston Churchill","Literature","1953")
INSERT INTO tblPersons VALUES ("Albert Camus","Literature","1957")
INSERT INTO tblPersons VALUES ("Albert Claude","Medicine","1974")
INSERT INTO tblPersons VALUES ("Woodrow Wilson","Peace","1919")
INSERT INTO tblPersons VALUES ("Marie Curie","Physics","1903")
INSERT INTO tblPersons VALUES ("Niels Bohr","Physics","1922")
INSERT INTO tblPersons VALUES ("Enrico Fermi","Physics","1938")
INSERT INTO tblPersons VALUES ("Louis de Broglie","Physics","1929")
INSERT INTO tblPersons VALUES ("Jaroslav Heyrovsky","Chemistry","1959")
INDEX ON category TAG category
CREATE table tblRating (category c(10),rating n(2))
INSERT INTO tblRating VALUES ("Economics",65)
INSERT INTO tblRating VALUES ("Literature",99)
INSERT INTO tblRating VALUES ("Medicine",71)
INSERT INTO tblRating VALUES ("Peace",50)
INSERT INTO tblRating VALUES ("Physics",1)
INSERT INTO tblRating VALUES ("Chemistry",90)
GO 2 && this record might be interesting
SCATTER NAME oUserSel && so remember it
SELECT tblPersons
* program will terminate at next statement due to syntax error
[COLOR=red]
LOCATE FOR category = M.oUserSel.category
[/color]
IF FOUND()
MESSAGEBOX("Found: " + tblPersons.name)
ELSE
MESSAGEBOX("Not Found")
ENDIF
During sleepless night I have find out, that there are a few ways to eliminate the problem.
- avoid indexing on field which is LOCATEd (comment out line "INDEX ON category TAG category" to see)
- disable using Rushmore optimization (add NOOPTIMIZE clause to LOCATE or SET OPTIMIZE OFF)
- eliminate use of object property in LOCATE statement (substitute it with standard variable MyVar = M.oUserSel.category)
- use SEEK M.oUserSel.category instead
This still doesn't give me an answer to what's going wrong with my LOCATE statement.
Will someone explain it to me? I smell a rat in Rushmore.
Thank you, Tom (VFP 7, SP1)