How to run tool with unsaved file
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
How to run tool with unsaved file
Is there a means of using a TextPad tool with an open window without first saving the file? I would like to be able to click the file->new, type in an SQL command and run, but Textpad requires me to save the file first. I'm new to TextPad (really like it a lot). I had been using Note Pad and was able to to this with that tool.
Re: How to run tool with unsaved file
Well, then I'm not sure what I am doing wrong. I have created a new Tool and Save All Documents is not checked.
Reply
I would like to configure a Tool that I can use with the active window rather than a saved file. This is what I hope to be able to do:
1-Open TextPad
2-Click the File New button (new window appears)
3-Type an SQL command in the new window
4-Run macro (execute the SQL I just typed) without saving the file
As I have the Tool configured now, when I run the macro, it prompts me to save the new file. If I don't give it a file name and save it, the command fails.
1-Open TextPad
2-Click the File New button (new window appears)
3-Type an SQL command in the new window
4-Run macro (execute the SQL I just typed) without saving the file
As I have the Tool configured now, when I run the macro, it prompts me to save the new file. If I don't give it a file name and save it, the command fails.
I think you may be misunderstanding what TextPad does. The macros in TextPad (its only weak point) have to be recorded as a sequence of keyboard strokes. If you write an SQL command and want to run it as a tool then I guess the tool you want to create will have the SQL interpreter as a command with the "Prompt for parameters" checked
The TextPad Tool works just fine currently, but only on a saved file. My former favorite editor (NoteTab), would execute simply using the active window. (I assume that it saved it as a temporary file somewhere) I thought perhaps TextPad had the same capability. I've looked through the TextPad help and can't find a way to do it.
Perhaps a future update to TextPad might offer a Tool Parameter Macro, something like $ActiveWindow, that could be inserted rather than $File. If the Tool Parameter were $ActiveWindow, it would simply create a temporary file and pass that to the application called by the TextPad tool.
Perhaps a future update to TextPad might offer a Tool Parameter Macro, something like $ActiveWindow, that could be inserted rather than $File. If the Tool Parameter were $ActiveWindow, it would simply create a temporary file and pass that to the application called by the TextPad tool.
I'm using Oracle 8i, via SQLplus. That's how I currently have the tool set up. As I mentioned earlier, TextPad is working very nicely, except that it seems to only work with a saved file. I don't understand how I could do it with a script, however.
I've toyed with the notion of a macro that would create a new file, copy the entire content of the active window to that file, save and close the new file, then execute the tool, calling that file as a Tool Parameter. I'm not sure whether that is even possible in TextPad.
I've toyed with the notion of a macro that would create a new file, copy the entire content of the active window to that file, save and close the new file, then execute the tool, calling that file as a Tool Parameter. I'm not sure whether that is even possible in TextPad.
Ed, That's precisely what I am doingl. The Tool calls sqlplus, an Oracle utility, and passes the name of the file to it. The TextPad Tool Parameter Macros don't seem to offer any means of getting at the active window, only a file saved from the active window, which, of course, requires saving the file first. I am currently looking at the $Clip Tool Macro to see if there is some way to use that, passing it to sqlplus. Maybe that is the solution?Ed wrote:I think you may be misunderstanding what TextPad does. The macros in TextPad (its only weak point) have to be recorded as a sequence of keyboard strokes. If you write an SQL command and want to run it as a tool then I guess the tool you want to create will have the SQL interpreter as a command with the "Prompt for parameters" checked
Based on the help topic Tool Parameter Macros, I'd say you're right that you can't pass a file until it is saved.
The $Clip parameter would probably work, depending on the application you're passing data to.
I've used $Sel with isql.exe .. which requires that you first select the line you want to execute. This allows me to keep several commands in one file, and literally select the one I want to execute.
HTH
The $Clip parameter would probably work, depending on the application you're passing data to.
I've used $Sel with isql.exe .. which requires that you first select the line you want to execute. This allows me to keep several commands in one file, and literally select the one I want to execute.
HTH
Hello,
I've written a program that lets you run a user-defined tool on an unsaved file (Tested with TextPad 4.7.2 on Windows XP Pro)
Create a user-defined tool following this example (@FILE is the placeholder):
- Command: C:\My Documents\ToolForUnsavedFile.exe
- Parameters: "C:\Program Files\SomeProgram.exe" -m -r @FILE -t 500
http://students.cec.wustl.edu/~plg1/Too ... edFile.exe
Please post feedback to this thread or email philipgump@yahoo.com
I've written a program that lets you run a user-defined tool on an unsaved file (Tested with TextPad 4.7.2 on Windows XP Pro)
Create a user-defined tool following this example (@FILE is the placeholder):
- Command: C:\My Documents\ToolForUnsavedFile.exe
- Parameters: "C:\Program Files\SomeProgram.exe" -m -r @FILE -t 500
http://students.cec.wustl.edu/~plg1/Too ... edFile.exe
Please post feedback to this thread or email philipgump@yahoo.com
I'm afraid that I'm a bit slow and would appreciate some further clarification. I downloaded the file, created a Tool and tried it but get the error: "The TextPad window appears not to be active."
The command line that I need to execute is:
sqlplus user/pass@db @filename
The Tool I created has:
Command: D:\Program Files\TextPad 4\ToolForUnsavedFile.exe
Parameter: "D:\Oracle817\bin\SQLPLUS.EXE" user/pass@db @@File
Thanks for your help.
The command line that I need to execute is:
sqlplus user/pass@db @filename
The Tool I created has:
Command: D:\Program Files\TextPad 4\ToolForUnsavedFile.exe
Parameter: "D:\Oracle817\bin\SQLPLUS.EXE" user/pass@db @@File
Thanks for your help.
Dont' worry; you're not slow! (Your command and parameters look fine.) I had incorrectly assumed that @File would be surrounded by spaces.
Update: http://students.cec.wustl.edu/~plg1/Too ... dFileB.exe
Hope this works! If not, let me know and I'll try again. Notice the new filename on the download.
Or if you want to mess around with it yourself, here's the code:
I wrote the program using AutoIt v3 (a very nice scripting language)
It can be compiled into an executable if you download AutoItv3Setup.exe from http://www.hiddensoft.com/autoit3/
Update: http://students.cec.wustl.edu/~plg1/Too ... dFileB.exe
Hope this works! If not, let me know and I'll try again. Notice the new filename on the download.
Or if you want to mess around with it yourself, here's the code:
I wrote the program using AutoIt v3 (a very nice scripting language)
It can be compiled into an executable if you download AutoItv3Setup.exe from http://www.hiddensoft.com/autoit3/
Code: Select all
; Program that lets you run a user-defined tool on an unsaved file
; Tested with TextPad 4.7.2 on Windows XP Pro sp1 using AutoIt 3.0.74
; Philip Gump - 10 November 2003 - v1.1
; Create a user-defined tool following this example (@FILE is a placeholder):
; Command: C:\My Documents\ToolForUnsavedFile.exe
; Parameters: "C:\Program Files\SomeProgram.exe" -m -r @FILE -t 500
AutoItSetOption("SendKeyDelay", 5) ;default is 10 ms
AutoItSetOption("WinWaitDelay", 100) ;default is 250 ms
AutoItSetOption("RunErrorsFatal",0) ;default is mode 1
;;; I've commented out this section due to the problem you had
; If Not WinActive("TextPad - ") Then
; MsgBox(0,"Error", "The 'TextPad' window appears not to be active!")
; Exit
; EndIf
;;;
; BackupClipboard, Copy buffer to clipboard, save tempFile, runTool, delFile
$ClipboardBAK = ClipGet() ;backup the clipboard--fails if non-text entry
$tempFile = EnvGet("TEMP") & "\" & "TextPad000.tmp"
$CmdWithArgs = ""
For $i = 1 to $CmdLine[0]
$arg = $CmdLine[$i]
; Allow characters to immediately precede or follow @FILE
; thus, I'm not assuming @FILE is delimited by spaces
$pos = StringInStr($arg, "@FILE")
If $pos <> 0 Then
$tmp = StringLeft($arg, $pos-1) & $tempFile
$tmp = $tmp & StringRight($arg, StringLen($arg)-$pos-4)
$arg = $tmp
EndIf
Select
Case $i = 1 ;build $CmdWithArgs so that first character is not a space
$CmdWithArgs = $CmdWithArgs & $arg & " "
Case StringInStr($CmdLine[$i], "@FILE")
$CmdWithArgs = $CmdWithArgs & " " & $arg & " "
Case 1=1 ;case else
$CmdWithArgs = $CmdWithArgs & " " & $arg
EndSelect
Next
Send("^a^c{HOME}") ;Ctrl+A (sel all), Ctrl+C (copy All), Home (unselect)
$content = ClipGet() ;stuff to be written to the tempFile
$handle = FileOpen($tempFile, 2) ;write mode 2 creates file via overwriting
If $handle = -1 Then
MsgBox(0, "Error", "Unable to create " & $tempFile)
Exit
EndIf
FileWriteLine($handle, $content)
FileClose($handle)
ClipPut($ClipboardBAK) ;restore clipboard
;MsgBox(0,"FOR DEBUGGING PURPOSES",$CmdWithArgs)
RunWait($CmdWithArgs) ;run command
If @error = 1
MsgBox(0,"Oops, the following command failed", $CmdWithArgs)
EndIf
FileDelete($tempFile) ;delete tempFile
Exit
Thanks very much for your incredibly creative solution. It works exactly as you suggested it would. The only downside, using your solution, I lose the capability of capturing the output of the command in the Command Results Window. The irony of this, it is the captured output that caused me to make the switch to TextPad from Note Tab Pro in the first place. Perhaps a future release of TextPad might provide the capability I was looking for.