<scriptlet>

<implements type='automation'>
	<method name='OpenTextFile'/>
	<property name='ShowConsole'/>
	<property name='ReadOnly'/>
	<property name='Arguments'/>
</implements>

<script language='vbs'>
Option Explicit

Const ShowConsole = 0
Const ReadOnly = False

Dim sh, fs
Set sh = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")

Function OpenTextFile(path)
	Dim astyle, options, optfile
	If Not IsEmpty(Arguments) Then Execute Arguments
	Select Case LCase(fs.GetExtensionName(path))
	Case "cs"
		options = options & " --mode=cs"
	Case "java"
		options = options & " --mode=java"
	End Select
	If Not IsEmpty(optfile) Then
		options = options & " --options=""" & optfile & """"
	End If
	options = options & " --stdin=""" & path & """"
	Set astyle = sh.Exec("""%WinMergeRoot%\astyle.exe""" & options)
	Set OpenTextFile = astyle.StdOut
End Function
</script>
</scriptlet>
