Add - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


ContextMenu[CurrentContext][EntryGenerators]

  

Add

  

add entry generator to EntryGenerators table for use within context menu module

 

Calling Sequence

Parameters

Description

Examples of EntryGenerators[Add]

Calling Sequence

EntryGenerators[Add](Name, Generator)

Parameters

Name

-

string; index of generator in 'EntryGenerators' table

Generator

-

list of lists or procedure that returns a list of lists; specifies the names that appear as subentries and the values returned when subentries are selected

Description

• 

The EntryGenerators[Add] command adds an entry generator to the context menu module.  Entry generators can be used by entries to dynamically generate subentries to obtain extra information from the user.

• 

The Generator parameter is a list of lists or a procedure that returns a list of lists.  If it is a procedure, then the selected object is passed to the procedure.

  

The list of lists is structured as follows.  Each operand in the outer list is a list, containing a string (the name of the subentry) followed by a list containing information to return to the entry as %ARG1, %ARG2, ...

  

For example, if Generator were [ ["Subentry 1", [1]], ["Subentry 2", [2]], ["Subentry 3", [3]] ] then "Subentry 1", "Subentry 2", and "Subentry 3" are displayed in the context menu.  If "Subentry 2" is selected, then 2 is returned as %ARG1 to the entry.

• 

The Name parameter is the index of the generator in the 'EntryGenerators' table.

Examples of EntryGenerators[Add]

with(ContextMenu[CurrentContext]):

  

Add an entry generator that allows the user to select a desired number of digits for approximation.

EntryGenerators[Add](
    "NumDigits",
    [ ["5",[5]], ["10",[10]], ["20",[20]], ["50",[50]], ["100",[100]] ]
);

  

Add an entry generator that allows the user to specify the direction and amount of rotation, for example, when rotating the elements of a list.

EntryGenerators[Add](
    "Rotation",
    [ ["2 to the left",[-2]], ["1 to the left",[-1]], ["1 to the right",[1]], ["2 to the right",[2]] ]
);

  

Add an entry generator that allows the user to select one of the variables that appears in the selected expression.  For example, this entry generator allows the user to select a variable with respect to which differentiation occurs or to specify the independent variable for a plot.

EntryGenerators[Add](
    "Variables",
    proc()
        local i, vars;
        try
            vars := Queries[Run]("Variables");
            [ seq( [ sprintf( "%a", op(i,vars) ), [ op(i,vars) ] ], i = 1 .. nops(vars) ) ];
        catch:
        end try;
    end proc
);

  

Add an entry generator that allows the user to select an ordered pair of the variables that appear in the selected expression.

EntryGenerators[Add](
    "Variables 2",
    proc()
        local i, vars, subentries;
        vars := Queries[Run]("Variables");
        subentries := combinat[choose](vars,2);
        [ seq( [ sprintf( "%a, %a", op(op(i,subentries)) ), op(i,subentries) ], i = 1 .. nops(subentries) ) ];
    end proc
);

See Also

ContextMenu

ContextMenu[CurrentContext][EntryGenerators]

EntryGenerators/Get

EntryGenerators/List