# Create function template in automatically

**URL:** <https://community.wolfram.com/t/create-function-template-in-automatically/284>\
**Category:** Questions\
**Tags:** mathematica\
**Created:** [July 29, 2013, 11:13am UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284 "2013-07-29T11:13:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kstolpovsky](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kstolpovsky/32/15607_2.png) [@kstolpovsky](https://community.wolfram.com/u/kstolpovsky)\
**Post date:** [July 29, 2013, 11:13am UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/1 "2013-07-29T11:13:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [July 29, 2013, 2:46pm UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/2 "2013-07-29T14:46:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kstolpovsky](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kstolpovsky/32/15607_2.png) [@kstolpovsky](https://community.wolfram.com/u/kstolpovsky)\
**Post date:** [July 29, 2013, 3:35pm UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/3 "2013-07-29T15:35:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kstolpovsky](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kstolpovsky/32/15607_2.png) [@kstolpovsky](https://community.wolfram.com/u/kstolpovsky)\
**Post date:** [August 1, 2013, 12:05pm UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/4 "2013-08-01T12:05:52Z")

</div>

Any ideas?

---

<div class="post-metadata">

**Author:** ![habudg](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@habudg](https://community.wolfram.com/u/habudg)\
**Post date:** [August 1, 2013, 2:54pm UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/5 "2013-08-01T14:54:52Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![kstolpovsky](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kstolpovsky/32/15607_2.png) [@kstolpovsky](https://community.wolfram.com/u/kstolpovsky)\
**Post date:** [August 2, 2013, 11:14am UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/6 "2013-08-02T11:14:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![habudg](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@habudg](https://community.wolfram.com/u/habudg)\
**Post date:** [August 2, 2013, 3:12pm UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/7 "2013-08-02T15:12:45Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![kstolpovsky](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kstolpovsky/32/15607_2.png) [@kstolpovsky](https://community.wolfram.com/u/kstolpovsky)\
**Post date:** [August 3, 2013, 2:49pm UTC](https://community.wolfram.com/t/create-function-template-in-automatically/284/8 "2013-08-03T14:49:40Z")

</div>

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.
