I am using UltraEdit as an external editor of Stata 14. Stata uses UTF-8 encoded text (without BOM) in command files (so called do-files).
To send (sections of) command files edited by UltraEdit directly to Stata I am using two AutoIt3 programs (rundo and rundolines defined as UltraEdit tools) written by Friedrich Huebler (see http://huebler.blogspot.ca/2008/04/stata.html) that allow to integrate external editors with Stata. rundo invokes Stata to run the complete command file from the disk, whereas rundolines copies selected parts of the command files into a temporary command file and invokes Stata to run this temporary file. If I save and edit the command file as a UTF-8 encoded file, calling rundo as an UltraEdit tool works fine.
However, using rundolines together with UltraEdit does not work as it should - it seems as if it is not possible to copy UTF-8 encoded edited in UltraEdit into the clipboard. The idea of rundolines is (1) to copy selected lines of from the editor into Windows' clipboard, (2) retrieve the user specific path of the temp directory, (3) create the temporary file "statacmd.tmp", (4) paste the commands from the clipboard into this file and place it into this directory, (5) activate Stata and (6) let Stata read and execute the commands of temporary file.
Unfortunately, even if a file with UTF-8 encoded text is edited in UltraEdit, copying UTF-8 encoded texts from UltraEdit into the clipboard seems to change them into a different encoding such that Stata will not display umlauts such as ä, ü, ö, or ß properly.
To fix this problem I inserted the following AutoIt3 script into line 60 of rundolines.au3 (the file is available at the link given above):
Note that in my case $tempfile of the script contains the path and file name "C:\Users\Enzmann\AppData\Local\Temp\statacmd.tmp". The idea of the fix is (1) to open the temporary files created by rundolines in UltraEdit, (2) convert the file from ASCII to UTF-8 (editable) and (3) save and close the file.
However, the fix does not always work properly because sometimes the first character of this string is stripped when it is copied into the window of the open file dialogue of UltraEdit using the AutoIt3 script command The problem seems to occur irregularly (sometimes the first, sometimes more, or sometimes no character is stripped from the path and file name string). I tried to avoid the problem by inserting a space character at the beginning of the string using which sometimes helps.
Does anybody know why the first character is sometimes stripped and how to avoid it?
The best solution were if it would be possible to copy UTF-8 encoded text into the clipboard. Friedrich Huebler reports that he is able to use rundolines successfully with NotePad++ (see http://www.statalist.org/forums/node/1300406). What is possible with NotePad++ should also be possible with UltraEdit.
To send (sections of) command files edited by UltraEdit directly to Stata I am using two AutoIt3 programs (rundo and rundolines defined as UltraEdit tools) written by Friedrich Huebler (see http://huebler.blogspot.ca/2008/04/stata.html) that allow to integrate external editors with Stata. rundo invokes Stata to run the complete command file from the disk, whereas rundolines copies selected parts of the command files into a temporary command file and invokes Stata to run this temporary file. If I save and edit the command file as a UTF-8 encoded file, calling rundo as an UltraEdit tool works fine.
However, using rundolines together with UltraEdit does not work as it should - it seems as if it is not possible to copy UTF-8 encoded edited in UltraEdit into the clipboard. The idea of rundolines is (1) to copy selected lines of from the editor into Windows' clipboard, (2) retrieve the user specific path of the temp directory, (3) create the temporary file "statacmd.tmp", (4) paste the commands from the clipboard into this file and place it into this directory, (5) activate Stata and (6) let Stata read and execute the commands of temporary file.
Unfortunately, even if a file with UTF-8 encoded text is edited in UltraEdit, copying UTF-8 encoded texts from UltraEdit into the clipboard seems to change them into a different encoding such that Stata will not display umlauts such as ä, ü, ö, or ß properly.
To fix this problem I inserted the following AutoIt3 script into line 60 of rundolines.au3 (the file is available at the link given above):
Code: Select all
; ---------- fix for UltraEdit 22.10: ---------
; Open temporary file in editor
$tempfile3 = " " & $tempfile
Send("^o")
Sleep($clippause)
Send($tempfile3 & "{Enter}")
Sleep($clippause)
; Convert file to UTF-8 coding (assumes UltraEdit's keyboard assignment to convert ASCII to UTF-8 is <Alt-u>)
Send("!u")
Sleep($clippause)
; Save and close temporary file (assumes UltraEdit's keyboard assignment to close a file is <Alt-s>)
Send("^s")
Send("!s")
; ---------- end fix for UltraEdit. ------------
However, the fix does not always work properly because sometimes the first character of this string is stripped when it is copied into the window of the open file dialogue of UltraEdit using the AutoIt3 script command
Code: Select all
Send($tempfile3 & "{Enter}")
Code: Select all
$tempfile3 = " " & $tempfile
Does anybody know why the first character is sometimes stripped and how to avoid it?
The best solution were if it would be possible to copy UTF-8 encoded text into the clipboard. Friedrich Huebler reports that he is able to use rundolines successfully with NotePad++ (see http://www.statalist.org/forums/node/1300406). What is possible with NotePad++ should also be possible with UltraEdit.