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

VFP9 error with ALLTRIM() in index "data type mismatch" 1

Status
Not open for further replies.

RafiAli

Programmer
Joined
Dec 12, 2001
Messages
4
Location
EU
Following works in VFP8 but _not_ in VFP9:

INDEX ON ALLTRIM(add_adr) TAG add_adr
FIND 'ABC'
---> VFP9 error: "Data type mismatch"

Add_adr is a character field. It's related to the ALLTRIM() in the INDEX expression; without that everything is OK. And, as I said, under VFP8 everything is OK too.

Any ideas?
Rafi
 
Could reproduce that but FIND is, I quote, "included for backward compatibility. Use SEEK instead.". And SEEK works. Seems they haven't tested that ;-)

Volker/
 

Rafi,

Yes, Volker's right. The FIND command takes a literal value, not an expression. In other words, if you say FIND Rafi, it would actually look for an index expression of Rafi, whereas if you do SEEK Rafi, it looks inside a variable called Rafi and search on whatever it finds there.

Personally, I haven't used FIND since about 1984, and I can't think of any good reason to do so.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
You also shouldn't use ALLTRIM() in an index expression.

From the help file:

"If you attempt to build an index with a key that varies in length, the key will be padded with spaces. Variable-length index keys are not supported in Visual FoxPro. "

Also see the language in the help file about creating index keys with a length of 0 (a possibility with Alltrim()).
 
Thanks everybody. I'd forgotten to mention that the SEEK works where the FIND doesn't. I'll go through all my code and replace them all. [mad]
Cheers,
Rafi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top