×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

ATAGINFO and Cursors
2

ATAGINFO and Cursors

ATAGINFO and Cursors

(OP)
Hi All,
This time my cursor issue is of the data table type.
I am using a grid to control "filtering" and navigation of records, common enough I think for us here.
But I wanted to create some different ordered views on the cursor, by issuing a series of "INDEX ON" commands after the table is created.
Then I have a drop-down box that I wanted to populate with the index tags, so you can just select a different order based on what tags are available for that cursor.
BUT, I'm finding that ATAGINFO() isn't working against the cursor, only a table.

For instance:

SELECT * FROM CUSTOMERTABLE INTO CURSOR CUSTOMERGRID READWRITE

SELECT CUSTOMERGRID
INDEX ON CUSTOMERNAME TAG NAME
INDEX ON COMPANYNAME TAG COMPANY
INDEX ON CUSTOMERSINCE TAG MEMBERSINCE

Then in the Requery of the dropdown, I have:
=ATAGINGO(aIndexTags,"CUSTOMERGRID")
naSize = ALEN(aIndexTags)/6

(The intention there is to just get the number of rows in the index, since ATAGINFO creates 6 "columns" for each tag).
But when it hits this line I get the error that:
Variable 'AINDEXTAGS" is not found.

But from the command window, if I issue this same call directly to the table (CUSTOMERTABLE) it works fine.
So is there some limitation of this with a CURSOR? And if there is, is there some other way I can dynamically get the indexes created for the cursor?

Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."hammer

RE: ATAGINFO and Cursors

Scott, I've been trying to replicate your problem. If I do exactly what you have done, the ATAGINFO() returns 0 and doesn't populate the array. Howerver, if I just pass the array name to ATAGINFO(), it seems to work correctly.

In other words, don't do this:

ATAGINGO(aIndexTags,"CUSTOMERGRID")


but instead do this:

ATAGINGO(aIndexTags)

I can't see why that should work. The Help clearly states that you can pass the alias as the second parameter. But that's what I am seeing (unless I've done something stupid, which is perfectly possible).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: ATAGINFO and Cursors

Parameterization has an optional cCDXname as second, but you can't skip it, if you give a second parameter, that is interpreted as cdx name. And for a cursor that isn't aliasname.cdx, just like DBF("aliasname") isn't the aliasname as file name. If you look at DBF("cursorname") you'll see a TMP file name.

You can call lnTagCount = ATAGINFO(laIndeTags,"","CUSTOMERGRID") to be very specific, or use the function in the same way as many functions and commands are usable without specifying an alias: For the current workarea, if "not otherwise advertised." - as Mike proposed already. I like to be more specific and you can be. You could also specify lnTagCount = ATagInfo(laTags,CDX(1,"CUSTOMERGRID")). There isn't CDX(aliasname), you need an index number, the alias name is optional, but as all tags are typically in the same CDX, CDX(1,cAlias) will always work, or CDX(1), but if you go for CDX(1) you can also leave off any parameterisation of ATAGINFO, aside of the result array name, because CDX(1) will then not differ from what ATAGINFOdetermines from DBF(), the current workarea DBF file, with extension changed to CDX.

And when we're at it, DBF(cAlias) allows you to make use of USE AGAIN or APPEND or other commands needing a DBF file rather than alias name. So you can get a second "record pointer" to a cursor if you USE DBF(cAlias) IN 0 AGAIN ALIAS newalias. and that was a way to get readwrite cursors from VFP6 query results, which didn't have READWRITE as an option of SQL-SELECT...INTO CURSOR, only NOFILTER, which means readonly results.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: ATAGINFO and Cursors

(OP)
Thanks to you both.
This is another one of those examples where "simple is better".
The mistake I made was not grasping what Olaf mentions (though now that I look at it, I SEE the why behind it). I was putting in the table name thinking that was the table, and not the .CDX and Olaf's explanation makes total sense of it. I was baffled by the result as well, but now it makes sense.
So if I just

SELECT CUSTOMERGRID
ATAGINFO(aIndexTags)

This should work fine. Will give it a whirl.
Cheers!

Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."hammer

RE: ATAGINFO and Cursors

(OP)
Just to confirm, as I was sure it would, it worked like a charm.
What I like most is that I understand WHY it works, so stars to you both.

Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."hammer

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close