On right click context menu could create "new text document."
I follow above link to make default UTF-8 encoding for new text document, but it's failure on Directory Opus. (12.4 / Win7 x86)
On right click context menu could create "new text document."
I follow above link to make default UTF-8 encoding for new text document, but it's failure on Directory Opus. (12.4 / Win7 x86)
Function NewUTF8file(FileName)
Dim NewFile, UTF8Blob
If Not DOpus.FSUtil.Exists(Filename) Then
Set UTF8Blob = Dopus.Create.Blob(&HEF, &HBB, &HBF)
Set NewFile = DOpus.FSUtil.OpenFile(FileName, "wc", "elevation")
NewUTF8file = NewFile.Write(UTF8Blob, 0,3)
NewFile.Close
Set UTF8Blob = Nothing
Set NewFile = Nothing
End If
End Function
newutf8file "d:\test.txt"
test ok
This button does not detect whether the filename is legitimate
<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none">
<label>button</label>
<icon1>#newcommand</icon1>
<function type="script">
<instruction>@script VBScript</instruction>
<instruction>Option Explicit</instruction>
<instruction>Function OnClick(ByRef clickData)</instruction>
<instruction>Dim dlg, ret, path</instruction>
<instruction>Set dlg = DOpus.Dlg</instruction>
<instruction>dlg.window = DOpus.Listers(0)</instruction>
<instruction>dlg.message = "File Name"</instruction>
<instruction>dlg.title = "new text document as UTF-8"</instruction>
<instruction>dlg.buttons = "OK|Cancel"</instruction>
<instruction>dlg.icon = "question"</instruction>
<instruction>dlg.defvalue = "New UTF-8 Text Document.txt"</instruction>
<instruction>dlg.max = 128 ' enable the text field</instruction>
<instruction>' Show the dialog and print the results to the script log</instruction>
<instruction>ret = dlg.Show</instruction>
<instruction>path = IIf(Right(clickData.func.sourcetab.Path, 1) = "\", clickData.func.sourcetab.Path, clickData.func.sourcetab.Path & "\")</instruction>
<instruction>If ret then</instruction>
<instruction> If Len(dlg.input) Then </instruction>
<instruction> NewUTF8File Path & dlg.input</instruction>
<instruction> Else</instruction>
<instruction> NewUTF8File Path & dlg.defvalue</instruction>
<instruction> End If</instruction>
<instruction>End If </instruction>
<instruction>End Function</instruction>
<instruction />
<instruction>Function IIf(ByVal Expression, ByVal TruePart, ByVal FalsePart)</instruction>
<instruction> If Expression Then IIf = TruePart Else IIf = FalsePart</instruction>
<instruction>End Function</instruction>
<instruction />
<instruction>Function NewUTF8File(FileName)</instruction>
<instruction>Dim NewFile, UTF8Blob</instruction>
<instruction> If Not DOpus.FSUtil.Exists(Filename) Then</instruction>
<instruction> Set UTF8Blob = Dopus.Create.Blob(&HEF, &HBB, &HBF)</instruction>
<instruction> Set NewFile = DOpus.FSUtil.OpenFile(FileName, "wc", "elevation")</instruction>
<instruction> NewUTF8file = NewFile.Write(UTF8Blob, 0,3)</instruction>
<instruction> NewFile.Close</instruction>
<instruction> Set UTF8Blob = Nothing</instruction>
<instruction> Set NewFile = Nothing</instruction>
<instruction> End If</instruction>
<instruction>End Function</instruction>
</function>
</button>