Saves the current query.
ade_id
ade_qrysave(
char* catname,
struct resbuf* qryparams);
Returns the ID of the newly saved query or ADE_NULLID.
catname | Category name. The category is created if it does not exist. |
qryparams | A resbuf list composed of an information type and a value. See the Information Types table below. |
name | Query name (RTSTR) |
description | Query description (RTSTR) |
qtype | How the query is saved (RTSHORT): 1 = internal (default), 2 = external. |
filename | For an external query, full path name (RTSTR). |
saveoption | Bit code for the save options you are choosing (RTSHORT). See the Save Options table below. |
The function saves the current query to the current drawing's query library or to a file.
- A query saved to the query library is called an internal query.
- A query saved to a file is called an external query.
You must specify a category name and a query name. In the current drawing and all attached drawings, no two queries can have the same name, even if they are saved in different categories. The default value for a description is the same as the query name. The default value for the storage type is internal. If you want to save the query externally, you must specify a file name for it.
1 | Keep reference in query library. |
2 | Save list of active drawings. |
4 | Save location coordinates. |
8 | Save current property alteration definition. |
16 | Execute automatically. |
A query gets a name and an ID only if it is referenced the query library. A new query that you have not yet saved does not have a name or an ID, and neither does an external query unless you keep a reference to it in the query library.
The following sample gets the location of the "QueryFileDirectory" using ade_prefgetval(). This path is combined with a query file name to create a parameter representing an external query. A resbuf is built which contains the name and description of an internal query plus the information required for the external query. Ade_qrysave() is called with with all required parameters, and the returned queryId is checked for value with an appropriate message displayed. All resbufs are then released, as required.
char* pszOptionVar = "QueryFileDirectory"; struct resbuf* pGetPrefValRb = NULL; pGetPrefValRb = ade_prefgetval(pszOptionVar); CString sQueryFileName = "Hydro-210.qry"; CString sQueryFilePath = pGetPrefValRb->resval.rstring; CString sQueryFileLoc = sQueryFilePath + sQueryFileName; struct resbuf* pQuerySaveParamsRb = acutBuildList( RTLB, RTSTR, "name", RTSTR, "Hydro-210", RTDOTE, RTLB, RTSTR, "description", RTSTR, "Hydro-210 description", RTDOTE, RTLB, RTSTR, "qtype", RTSHORT, 2, RTDOTE, RTLB, RTSTR, "filename", RTSTR, sQueryFileLoc, RTDOTE, RTLB, RTSTR, "saveoption", RTSHORT, 3, RTDOTE, RTLE, 0 ); char* pszQueryCatgryName = "Hydrology"; ade_id queryId = ade_qrysave(pszQueryCatgryName, pQuerySaveParamsRb); if (queryId != ADE_NULLID) { acutPrintf( "\nA query has been saved to the internal library: \"%s\"" , pszQueryCatgryName); acutPrintf( "\nAn external query has been saved as: %s" , sQueryFileLoc); } else { acutPrintf( "\nNo queries have been saved."); } acutRelRb(pGetPrefValRb); acutRelRb(pQuerySaveParamsRb);