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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SEEK() function name missing

Status
Not open for further replies.
Sep 17, 2001
673
US
I am trying to use seek() function on a table during a scan on a different table. If you create a simple table and index a field in the table. Then do SEEK("xyz","Ctest_table","Tag") It comes back with 'function name missing'. Whats up with this?

Regards,

Rob
 
Just add "=" to the beginning:
=SEEK("xyz","Ctest_table","Tag")
-or-
lFound = SEEK("xyz","Ctest_table","Tag")

SEEK() is an older VFP function and it returns a value. You need to do something with it.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I think if you look more closely, you'll see the actual message is "Function name is missing [red])[/red]."

Dave's answer is correct though - if you assign the function to a variable, the error does not occur.

INDEXSEEK() is probably the function you want to use instead of SEEK(). It has more options and does not doesn't need to be assigned to a variable.

Mike Krausnick
Dublin, California
 
SEEK() is an older VFP function and it returns a value. You need to do something with it.

It seems to be a bit more complicated than that and I don't understand it at all.

I habitually call Fox functions without an "=" sign and I've just checked that:
Code:
SEEK("BOLID")
works with the sample Customer table.

If open and select the Employee table and try either of these:
Code:
SEEK("BOLID", "Customer")
SEEK("BOLID", 1)
then I get the "Function name is missing )" message. I've tried in Fox 6 and Fox 9.

Help tells me that:

"The function contains too many arguments and thus the right parenthesis is undetected."

The SEEK() function with two parameters will work if I add an "=" sign and throw away the answer.

Odd isn't it?

Geoff Franklin
 

This is very rum. I have never before heard of a case where simply preceding the function name with an '=' sign masked an error. Surely it can't be the intended behaviour?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
hi, for use seek do like this

example with table name= client
index on cli tag cli

select client
set order to cli
seek '1'

this going to seek the client with 1 in the cli field.

hope its help
coco10
 

The word "Seek" appears twice in the Fox language, once as a command and once as a function. The example you give is the Seek command which finds an indexed value and moves the record pointer. The function does the same thing but also returns a value to tell you whether the search has succeeded. Seek("1") would look for client "1" and return .T. if that client is found. It's a combination of the Seek command and the Found() function.

Geoff Franklin
 
yes this its true, now i dont know why you want to use in the another way, if you want to know its found or not do like this

select ZZZ
set order to p
seek 1
if found()

else

endif

if you dont want to use a index use locate command

coco10
 
Here's another twist:
The following code works in VFP9:
Code:
USE mytable
IF SEEK("somekey","mytable","somekeytag")
	MESSAGEBOX("Found")
ELSE 
	MESSAGEBOX("Not Found")
ENDIF

So you don't need the = sign, you just can't use a bare SEEK() - reinforcing Dave's point that you have to use the result. Perhaps the odd behavior is some sort of backward compatibility issue.

For my money, using INDEXSEEK() would be more reliable. Just run your project through GOFISH, do a global change and be done with it.

Mike Krausnick
Dublin, California
 
Perhaps the odd behavior is some sort of backward compatibility issue.
Might be. I've just tried it in FPW26 and found that I can say:
Code:
SEEK("ALFKI")
without an equals sign but I get an error from:
Code:
SEEK("ALFKI","Customer")
unless I at least put an equals sign in front of it.

I'm not going to fret too deeply about this behaviour because I don't use SEEK() unless I need the result. I only became interested because I do sometimes use functions like ADIR() or ADEL() without bothering with the value they return.

Geoff Franklin
 
What's going on here is that the FoxPro parser needs some way to distinguish the SEEK command from the SEEK() function, so unlike most functions, you do need to do something with the result.

Tamar
 
As always great thoughts and replys. I went with the SEEK command and it worked fine. I did verify that it works fine if I have = in front of the seek() function.

Regards,

Rob
 

Tamar,

What's going on here is that the FoxPro parser needs some way to distinguish the SEEK command from the SEEK() function, so unlike most functions, you do need to do something with the result.

That explains a lot.

I wonder if it's the same with SELECT and SELECT().

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
I wonder if it's the same with SELECT and SELECT()

Sitting here with Customer and Employee tables open:
Code:
SELECT() - 'Missing Operand'
SELECT(0) or  SELECT(1) - 'Command is missing required clause'
SELECT("employee") - Selects the Employee work area.
SELECT ("1") - 'Alias "1" is not found'
SELECT ("a") - Selects the Customer work area

It looks as though the parser recognises that I'm using SELECT as a command rather than as a function and treats the brackets as a named expression rather than as a parameter.

Geoff Franklin
 

Geoff,

That makes good sense -- and ties in with what Tamar said.

I guess an important difference between SEEK() and SELECT() in this context is that SEEK() actually does something, whereas SELECT() is only useful in terms of the value it returns. In other words, you would not normally use SELECT() except by looking at the returned value.

An interesting discussion.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top