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

ASCAN - Advanced Settings 1

Status
Not open for further replies.

jimoo

Programmer
Jun 2, 2003
1,111
US
I am using some of the new features in the ASCAN function to specify a column, and to set the EXACT Value to TRUE. However, it is not working correctly. Maybe I misread the documentation.

I want to scan for a fieldname, limit it to the first column for efficiency & safety, and match "EXACT" value.

Thus, I don't want my search of "BO" to return a hit on "BOB"

Here is the some sample code that demonstrates the problem. It returns 0.

If I change the last parameter from 6 to 1 it returns 19, which is 2nd element, 1st item (2,1).

I am expecting 54. which is 4,1

* Also - I am aware that setting EXACT ON will resolve my problem, but according to the documentation I should not have to do that.

Code:
SET EXACT OFF
CREATE TABLE DELETEME (NO C(10), BOB C(10), JO C(10), BO C(10))

lcFieldName = "BO"
lnFieldCount = AFIELDS(laTemp,"deleteme")
lnSeed = ASCAN(laTemp,[&lcFieldname],1,-1,6) 

MESSAGEBOX(ALLTRIM(STR(lnSeed)))
USE
DELETE FILE DELETEME.dbg

Jim Osieczonek
Delta Business Group, LLC
 
You're missing a parameter aren't you? [smile]

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Here this will show the differences for anyone who might be interested in the future...

Code:
SET EXACT OFF
CREATE cursor DELETEME (NO C(10), BOB C(10), JO C(10), BO C(10))

lcFieldName = "BO"
lnFieldCount = AFIELDS(laTemp,"deleteme")
FOR lnCounter = 0 TO 15
 lnSeed = ASCAN(laTemp,lcFieldName,1,-1,1,lncounter)
 ?lnSeed
ENDFOR
USE

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Jim,
At least one problem and one extra complication you probably don't need. The first is a missing parameter in ASCAN() and the second is you really don't need [&lcFieldName].
Code:
...
lnSeed = ASCAN(laTemp,[b]cFieldname[/b],1,-1,[red]1[/red],6) 
...

DELETE FILE DELETEME.[red]DBF[/red]
Rick
 
Yep - I figured it out with the help of Craig's first suggestion (missing parm) and reading the help a bit more carefully.

Rick, yep - I noticed the misspell of the dbf. I must be used to DBG

I'll try it without the & in front of the fieldname.

Here is what I used:
lnSeed = ASCAN(laTemp,[&lcFieldname],1,-1,1,6)


Jim Osieczonek
Delta Business Group, LLC
 
I think this is one of those goofey times you need the &

I removed it from the code and it errored. I even placed () around the variable lcFieldName and it still errored.


Code:
SET EXACT OFF
CREATE TABLE DELETEME (NO C(10), BOB C(10), JO C(10), BO C(10))

lcFieldName = "BO"
lnFieldCount = AFIELDS(laTemp,"deleteme")
lnSeed = ASCAN(laTemp,[&lcFieldname],1,-1,1,6) 

MESSAGEBOX(ALLTRIM(STR(lnSeed)))
USE
DELETE FILE DELETEME.dbf

Jim Osieczonek
Delta Business Group, LLC
 
Jimoo,

I think Rick is right. I just tested your code without [&] it works.
Code:
SET EXACT OFF
CREATE TABLE DELETEME (NO C(10), BOB C(10), JO C(10), BO C(10))

lcFieldName = "BO"
lnFieldCount = AFIELDS(laTemp,"deleteme")
lnSeed = ASCAN(laTemp,[b]lcFieldname[/b], 1,-1,1,6) 

MESSAGEBOX(ALLTRIM(STR(lnSeed)))
USE
DELETE FILE DELETEME.dbf

-- AirCon --
 
Yes it does. I'm using VFP7 and it returned 49.

-- AirCon --
 
Sorry, press submit too fast :)

Are you using VFP8? Because the one that I am using (VFP7), each field has 16 columns. So 49 is array[4,1]

-- AirCon --
 
I am using VFP 8.

You bring up a good point. Rather than hard coding the 18 I should use the ALEN(myarray,2) to get the number of elements since it has changed in past versions and could change again.

Jim Osieczonek
Delta Business Group, LLC
 
Or you can get the row directly:

lnSeed = ASCAN(laTemp, lcFieldname, 1,0,0,14)
? lnSeed && returns 4

Many ways to skin Fox :)

-- AirCon --
 
jimoo,

Are you saying that running the code I posted above will error out in VFP 8? I don't think that is possible, and if it is, I would be very interested to know what the error you get is. Also, if the code I posted above doesn't give you the following 16 values printed in the screen when you run it in VFP 8:

17
17
17
17
17
17
49
49
2
2
2
2
2
2
4
4

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top