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!

ATAGINFO and Cursors 2

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,826
JP
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]
 
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:
[tt]
ATAGINGO(aIndexTags,"CUSTOMERGRID")[/tt]

but instead do this:

[tt]ATAGINGO(aIndexTags)[/tt]

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
 
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 [tt]lnTagCount = ATAGINFO(laIndeTags,"","CUSTOMERGRID")[/tt] 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 [tt]lnTagCount = ATagInfo(laTags,CDX(1,"CUSTOMERGRID"))[/tt]. 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
 
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]
 
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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top