Message Boards Message Boards

0
|
3517 Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

Create function template in automatically

Posted 11 years ago
Dear friends.
My aim is to generate a code. This new code has to include different not known in advance functions. When the notebook gets a new function it should be able to insert appropriate arguments. If I do it manually I can use "Edit ? Make Template" function. The question is: how to do it automatically?

I also know about the Information function, but it is not what I need exactly.

In addition, how can I learn the type of variable?

Thanks in advance.
7 Replies
This is a useful part of the code, thanks a lot!

However, I need more. As I said in the beginning, the function is not known in advance and the program should be able to put the appropriate arguments. So the problem might be split up into two steps:

1) to determine the expected types of arguments;

2) to find an appropriate arguments among available. 
Posted 11 years ago
OK. You want it done programmatically. Your reference to automatically was a little ambiguous.

I don't do a lot of Notebook programming, but as a very basic start you could try something like the following.

 NotebookWrite[InputNotebook[],
  Cell[BoxData[
    RowBox[{"Plot", "[",
      RowBox[{ TagBox[FrameBox["f"], "Placeholder"], ",",
        RowBox[{"{",
          RowBox[{ TagBox[ FrameBox["x"], "Placeholder"], ",",
            TagBox[ FrameBox["xmin"], "Placeholder"], ",",
            TagBox[ FrameBox["xmax"], "Placeholder"]}], "}"}]}],
      "]"}]], "Input"]]

For more details, you can look under Notebooks and Documents in the Documentation Center.
POSTED BY: David G
Posted 11 years ago
Look for Edit -> Make Template in the Documentation Center. There, you will find the key shortcuts for the various OS. For Windows, it is Shift+Ctrl+K. Also, you must have the full command name on the input line, eg Plot (not pl, or Plo, etc).
POSTED BY: David G
Yes, I know about Shift+Ctrl+K and I already have a list of all full commands. The question is how I can automate it. In other words, how I can make a program to "press" Shift+Ctrl+K.
Any ideas?
Easily.
For example I got a function Plot.
Then I have a function f=X^2, variable X and two numbers a=1 and b=2. What I want is to generate a line Plot[X^2, {X,a,b}]
That's it.
It is difficult to tell what exactly you want. If you provide a concrete example of a simple input and desired output (or other aspects of the processing) then this might become easier to answer.
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract