Create new text file opened?

Forgive my ignorance as I'm new to Dopus but I'm trying to make a button that creates a new text file in the active lister, opens it, pastes contents of clipboard and then saves and closes the file. If this is not possible then at least a button that creates a new text file that is open in a text editor so I can then use a keyboard shortcut and run an external macro program to do the rest. If I was to go to File>New>New Text Document on the menu, the new document is highlighted and I can just run a macro starting to open it. With a button using the command "filetype NEW=.txt", the new text document is created but is not highlighted so i then have to find it in the lister dbl click on it etc.
Forgive me if I'm lacking in a basic understanding of the Raw commands but if anyone could help me with this I would really like to have this button.
Thanks

I assume you know the very basics of creating a button, if so here's 3 button command lines that might get you started.

Clipboard PASTE
Select NONE
Select "Clipboard Text.txt"

The first line creates a new text file in the active lister named Clipboard Text.txt whose contents contain the text in the Windows clipboard

The second line deselects anything that had been previously selected.

The third line selects the new file you just created.

Thanks JohnZeman. Works perfectly! That's exactly what I wanted it to do. Really appreciate you taking the time to help me out with that.

I'm maybe missing something, but it looked like the goal behind the selection of the new file seemed only to serve the next goal of then opening the file in a text editor, and then just to paste the clipboard contents into the newly created file...

Doesn't hitting <CTRL+V> while inside a lister automatically do all this?

Yup steje that's right.

I only included the extra lines because I figured simonsmith_7 would want to do something with the file after it was created so I highlighted it. The reason I didn't take it further is because Simon says he is new to buttoning so I didn't want to hit him with too much at one time.

Logically the button commands could be extended to something this to make it something a little more useful.

Select NONE
Clipboard PASTE
Select "Clipboard Text.txt"
Rename TO "{dlgstring|Enter a new file name without the extension}.txt"
@nodeselect

JohnZemans origional 3 commands are just perfect for me because I already have a button for renaming selected files from the clipboard. I am primarily copying a lot of blocks of text from the internet. As the text file is now selected when I create it I can go back to the origional text, choose a keyword to rename the file and then just hit the "rename from clipboard" button without having to find the file in the lister to select it. This save me a great deal of time.
Thanks again to JohnZeman