Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with Seek

Status
Not open for further replies.

stanlyn

Programmer
Sep 3, 2003
945
US
Hi,

Can anyone point out what is wrong here? I'm getting an error dialog of "Compile, Function name is missing" when saving.

Code:
lnPK = ActionDetail.task_pk
SEEK (lnPK, 'task', 'PriKey')

where 'ActionDetail.task_pk' is valid and is equal to 16
and 'task' is the lookup table
and 'PriKey' is the lookup table's index built on task.pk
and task table does contain a record whose PriKey value is 16

I've also taken the space from between k and (. "seek (" and/or "seek(" - same error.
Thanks,
Stanley


 
What if you change the SEEK part to:

Code:
IF SEEK (...)
   * Do something
ENDIF

or to:

Code:
SEEK lnPK IN Task ORDER PriKey

That is, you're using the SEEK function rather than the SEEK command, but you're not doing anything with the result.

Tamar
 
Hi Tamar,

I need to move the pointer in the 'task' table if found('task') returns true.

seek something
if found()
do something

I can see the logic in both your examples. Just trying to understand what the function name missing was about...

Thanks,
Stanley
 
Well, SEEK is both a function and a command. The way you used it confused the compiler.

I would prefer using the function, as its return value already tells you the FOUND() status. But if your VFP version is not having it, you must use the command variant.

If you're just used to the command variant, and have code following with IF FOUND(), then make it this way, perhaps:

Code:
llFound = SEEK(lnPK, 'task', 'PriKey')

IF llFound && instead of FOUND()
...
ENDIF

I tested SEEK(lnPK, 'task', 'PriKey') and SEEK (lnPK, 'task', 'PriKey') at the command line and both variants cause a "function name is missing )" error, but ? SEEK(lnPK, 'task', 'PriKey') or ? SEEK (lnPK, 'task', 'PriKey') work. The ? makes clear the SEEK function is meant and not the command working on whatever the brackets return.

I always use SEEK() within IF SEEK() lines, it makes clear the SEEK function is meant and the compiler doesn't get confused.

Bye, Olaf.

 
SEEK, whether you use the command or the function, automatically moves the record pointer.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top