Associate Compiler Program with File types

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
dFoxGuru
Posts: 1
Joined: Thu Dec 11, 2003 11:00 pm

Associate Compiler Program with File types

Post by dFoxGuru »

Right now I create a run command and add it to the menu to compile a file type.

It would be nice if I could associate a compiler program definition with a file type and then have only one 'Compile' option in the menu. The menu option would be disabled if the active file has no associated compiler program. Associating a compiler would be done through the existing file types definitions.
It's not about setting goals. It's about soaring beyond them. Dr. Maxwell
User avatar
CyberSlug
Posts: 120
Joined: Sat Oct 04, 2003 3:41 am

Post by CyberSlug »

By next week, I hope to have something like this in my collection of tools:
http://www.textpad.com/forum/viewtopic.php?t=4721

Could you provide a list of the file types and compiler command line arguments you use?

Here's a partially working script....

Code: Select all

; Requires AutoIt3.exe from http://www.hiddensoft.com/autoit3/

;===================================================================\
; Compile a file according to its document class.
;   Philip Gump - 11 December 2003
;
; Command: AutoIt3.exe
; Parameters: "C:\pathToThisScript\Compile.au3" $file [any and other]
;
; YOU WILL NEED TO MODIFY SECTION THREE!
;===================================================================/

;;FIRST, determine the class (file extension) of the active document.
$titles = WinGetText("TextPad - ","")
$tmp = StringLeft($titles, StringInStr($titles, Chr(10)))   ; file path

While StringInstr($tmp, ".") <> 0   ; path may contain many dots
  $tmp = StringTrimLeft($tmp, StringInstr($tmp, "."))
WEnd
If StringInstr($tmp, "*") <> 0  ; file was modified since last save
  $class = StringTrimRight($tmp, 3)
Else
  $class = StringTrimRight($tmp, 1) ; need to remove carriage return
EndIf
; We now have the file extension (stored in variable $class)!


;SECOND, Get command line arguments ....
$file = ""
$arg2 = ""
If $cmdLine[0] == 0 Then
	MsgBox(0,"Error", "This tool needs command line arguments!")
	Exit
Else
	$file = '"' & $cmdLine[1] & '"'   ; enclose path/file in quotes
	;;;$arg2 = $cmdLine[2]  ; sample second argument
EndIf


;;THIRD, run the appropriate compiler
Select
	Case $class = "c" OR $class = "cpp"
		Run('something something ' & $file)
	Case $class = "java"
		Run('"c:\windows\foo\javac.exe" -classpath ' & $file)
	Case $class = "au3"
		Run('"C:\Program Files\AutoIt3\Aut2Exe\Aut2Exe.exe" /in ' & $file)
	Case Else
		MsgBox(0,"Error", "No command specified for " & $class & " file type.")
	Exit
EndSelect
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Thought I'd throw a few out for you

Code: Select all

   Case $class = "c" OR $class = "cpp" 
      Run('c:\minGW\bin\gcc.exe ' & $file)
      ;; Run('c:\cygwin\bin\gcc.exe ' & $file)
      ;; Run(c:\borland\bcc55\Bin\bcc32.exe ' & $file)
   Case $class = "py" 
      Run('c:\python23\python.exe ' & $file) 
      ;; Run('c:\python22\python.exe ' & $file) 
   Case $class = "js" OR  $class = "vbs" 
      Run('c:\winnt\system32\wscript.exe ' & $file) 
   Case $class = "pl" 
      Run('c:\perl\bin\perl.exe ' & $file) 
I choose to fight with a sack of angry cats.
User avatar
ramonsky
Posts: 88
Joined: Fri Nov 14, 2003 10:54 am

Post by ramonsky »

Actually, it would be simple (and cool) if the tools displayed on the tools menu could be dependent upon the file extension of the current file. Thus, if you're editing a Java file, tools such as "Compile Java", "Compile Java to DLL", "Run Java" , etc., could magically become visible. Selecting a PHP document makes all these entries disappear, but others such as "Run PHP" become visible.

I'd like this. Sounds easy to do, too.

Jill
User avatar
CyberSlug
Posts: 120
Joined: Sat Oct 04, 2003 3:41 am

Post by CyberSlug »

ramonsky wrote:Actually, it would be simple (and cool) if the tools displayed on the tools menu could be dependent upon the file extension of the current file.
I agree!!

We should be able to create global tools (available to all file classes) AND local tools (available to the active file class).

There should be one tool/button/keyboard-binding for things like "compile" and "comment/uncomment" so that we don't have to keep re-defining them which clutters up the tool menu!
Post Reply