ContextMenu[CurrentContext][Queries][Add] - add query for use within context menu module
|
Calling Sequence
|
|
Queries[Add](nm, query)
|
|
Parameters
|
|
nm
|
-
|
string; name by which query is referenced
|
query
|
-
|
procedure; returns information about the right-clicked object
|
|
|
|
|
Description
|
|
•
|
The Queries[Add] command adds query to the set of recognized queries under the name nm.
|
•
|
The nm parameter is the name by which the query is used and referenced by the context menu module. The query parameter is a procedure applied to the selected object.
|
•
|
Note that if a query is boolean-valued, meaning it returns true, false, or FAIL, then nm may be used in the test parameter to the Entries[Add] command. This indicates that the appearance of the associated entry in the context menu is dependent on the return value of query.
|
•
|
In addition to their use in Entries[Add], queries may be called by entry generators (see EntryGenerators) or by other queries using the Run command.
|
|
|
Examples of Queries[Add]
|
|
>
|
with(ContextMenu[CurrentContext]):
|
|
Add a query that lists the exports of a specified module.
|
>
|
Queries[Add]("Exports", proc(e) [exports(e)] end proc);
|
|
Add a query that returns the number of exports a specified module has.
|
>
|
Queries[Add]("NumExports", proc(e) nops(RunQuery("Exports", e)) end proc);
|
|
Add a query that tests that the specified module has exactly five exports.
|
>
|
Queries[Add]("5 exports", proc(e) evalb(RunQuery("NumExports", e) = 5) end proc);
|
|
|
Download Help Document
Was this information helpful?