Open file in New UE Window

This forum is user-to-user based and not regularly monitored by IDM.
Please see the note at the top of this page on how to contact IDM.

Open file in New UE Window

Postby Tookelso » Wed May 17, 2006 3:43 pm

Hello,

I do not use "Allow Multiple Instances". Most of the time I want to have all my documents open under the same window.

However, I have two screens at work, and it would be nice to open a new ultraedit window sometimes.

Is there a quick/easy way to open a file in a new ultra edit window, without going to the Settings and clicking "Allow Multiple Instances"?

Thanks
--Nate
User avatar
Tookelso
Newbie
 
Posts: 6
Joined: Tue Jan 25, 2005 12:00 am

Re: Open file in New UE Window

Postby Acid » Wed May 17, 2006 11:29 pm

I know what you mean. As far as i know it is impossible to get an "edit"-window out of UE so if you really want a seperate window on your second screen you will have to start a new instance of UE.

Although it is possible to resize UE so it covers most of your two screens so you can move the edit windows around. The down side is that UE will cover most of your desktop and everytime you want to type somthing UE will take focus and hide most of your desktop.

Image
User avatar
Acid
Basic User
Basic User
 
Posts: 21
Joined: Thu Jan 26, 2006 12:00 am

Re: Open file in New UE Window

Postby Mofi » Thu May 18, 2006 5:48 am

Sorry, no! You cannot start a new instance of UltraEdit without disabling Allow Multiple Instances, except you use UltraEdit v13.10 or later.

I would suggest to write an feature request by email to IDM support (see email address at top of this page) and ask for a command line parameter which forces UltraEdit to ignore the Multiple Instances setting in the INI and always starts UE in a new instance. Then you would only need a shortcut or an UltraEdit tool to uedit32.exe with this parameter to start UE in a new instance without changing the setting. I would support this additional command line parameter feature request.

As workaround you can create copies of the uedit32.* files with a different file name like ue2.* in the same directory as uedit32.ini, set once in ue2.ini the setting "Multiple Instances" to 1 and run uedit32.exe with the command line parameter /i="path to uedit32.ini\ue2.ini" via shortcut or UltraEdit user tool.

The disadvantage of the second INI file approach is that you have to make all settings now always twice and the histories (find, replace, ...) are different for standard instance and the second instance. There are also problems during updates to new major releases of UltraEdit. You have to always sychronize after an update the second INI with the content of the first INI except the "Multiple Instances" setting.

To reduce the disadvantages of the second INI file approach as much as possible you could also create a batch file which has following commands:

@echo off
copy /y "path to uedit32.ini\uedit32.*" "path to uedit32.ini\ue2.*" >nul
"path to Xchang32.exe\Xchang32.exe" /s "path to uedit32.ini\ue2.ini" "Multiple Instances=0" "Multiple Instances=1" >nul
"path to uedit32.exe\uedit32.exe" "%1" /i="path to uedit32.ini\ue2.ini"


Xchang32.exe is a free 32 bit console application for replacing text in files. You can get it from Clay's Utilities. Run this batch file via a shortcut or an UltraEdit user tool to start a new instance of UltraEdit with current stored settings of uedit32.ini.

Edit: Added "%1" to the last line of the batch file. Now it is possible to run the batch file with an UE user tool and pass the current file name with "%f" to the batch file to automatically open the current file in a new instance of UE.

It's even possible to open the current file in the new instance of UE and place the cursor exactly to the same position as it is in the current instance of UE. In the user tool the options %line% and %col% (in this sequence) must be used on the command line. And in the batch file you have to modify "%1" to "%1/%2/%3".
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4069
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Open file in New UE Window

Postby Tookelso » Thu May 18, 2006 5:36 pm

Thanks for the replies.

I made a feature request for Firefox-like functionality. In Firefox, you can right-click on a link, and select "Open in New Window". In ultraedit, you could right-click in a file, and the option to open in a new window would be there.

I tried my own kludge. Here's how it goes:
I have a Perl script which goes into the INI file and changes "Multiple Instances=0" to "Multiples Instances=1".
Then, the script calls UE, passing the currently open filename.
Then, the script goes back into the INI and changes the "Multiple Instances=1" to "Multiple Instances=0".

In UltraEdit, you go to Advanced....Tool Configuration and set up a new command where you call new_ue_window.pl %f

It *does* spawn a new window with your file in it.

However, it gets quirky from here.
Since you spawned a new UE window with "Multiple Instances=0", then if you close the new Window, UE will overwrite the INI file with "Multiple Instances=1".

As soon as you close the original UE window, the "Multiple Instances=0" is restored. So if you can live with that, then this solution's o.k.

If anyone wants the Perl script, I enclosed it below. Copy and paste the following into a file and name it "new_ue_window.pl"

You'll also need at least perl 5.8.0 installed, and in your PATH. Ultraedit also needs to be in your PATH.

-------------BEGIN PERL---------------
# new_ue_window.pl

# This perl script modifies the ultra-edit INI file to
# allow multiple instances. It then calls ultra edit, passing
# ultra edit the name of the file.

use strict;
use warnings;

use POSIX qw/strftime/;
use File::Copy;

my $file = shift or die "ultra_edit.pl <1|0> 1 for multiple instances, 0 for not.";

my $INI_FILE = $ENV{APPDATA} . '/IDMComp/UltraEdit/uedit32.INI';
my $INI_BACKUP = $INI_FILE . '_' . strftime("%Y_%m_%d_%H_%M_%S", localtime());
# Make a backup.
copy($INI_FILE, $INI_BACKUP) or
die "Could not copy '$INI_FILE' to '$INI_BACKUP' -- $!";

my $exe = $ENV{ProgramFiles} . '/IDMComp/UltraEdit/uedit32.exe';

turn_multiple(1);
system("start uedit32.exe $file");
sleep(2);
turn_multiple(0);

print "Finished";
exit 0;

sub turn_multiple {
# 0 for off, 1 for on.
my $allow_multiple = shift;

my @settings;

open FILE, $INI_FILE or die "Couldn't open '$file' -- $!";
while(<FILE>) {
# print "Before '$_'\n";
s/^Multiple Instances=\d/Multiple Instances=${allow_multiple}/;
# print "$_";
# print "After '$_'\n";
push @settings, $_;

}
close FILE;

# Write INI file with new settings
open FILE, ">", $INI_FILE or die "Couldn't open INI file '$file' -- $!";
foreach my $setting(@settings) {
print FILE $setting;
}
close FILE;
}
User avatar
Tookelso
Newbie
 
Posts: 6
Joined: Tue Jan 25, 2005 12:00 am

Re: Open file in New UE Window

Postby Acid » Thu May 18, 2006 8:40 pm

Wouldn't it be possible to have a "windowless" editor like GIMP. Every toolbar and window in windows. It can be minimized and everything. This would be quite handy for multi screen setups.

Gimp screenshot: http://mmmaybe.gimp.org/screenshots/win ... nshot2.png
User avatar
Acid
Basic User
Basic User
 
Posts: 21
Joined: Thu Jan 26, 2006 12:00 am

Re: Open file in New UE Window

Postby Tookelso » Fri May 19, 2006 12:03 am

I totally missed an obvious answer, and that is to have another program open the currently active document.

"Duh" on me.

We have TextPad 4 here at work. I just configured a Windows Command that runs TextPad with the active file.

This will be good enough for now.

Thanks,

--Nate
User avatar
Tookelso
Newbie
 
Posts: 6
Joined: Tue Jan 25, 2005 12:00 am

Re: Open file in New UE Window

Postby Bego » Fri May 19, 2006 5:55 am

Hi Tookelso,

hmm, I think Mofis approach is quite practicable.
--> there is always a "new" Ini derived from your "real" ini
--> No "quirky" stuff

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Open file in New UE Window

Postby Bego » Fri May 19, 2006 11:21 am

When doing it with a batch file, a stupid DOS box stays open. I hate that and did not yet get rid of it.
So I made a vb-script file called ue_new_Instance.vbs.
You have to modify the red code-passages and have implement the copy too (I can live without a ini-copy, I do this by hand from time to time).
I also made a link to this script in the "send to" Folder and named it "Ultraedit_NEW_INSTANCE". Quite comfortable now :-)

Option Explicit

Dim shell
Dim args
dim fil
DIM fso
DIM STRCMD1
DIM STRCMD2
dim STRINI
dim strCmd
dim QUOTE
QUOTE = """"
STRCMD1 = QUOTE & " C:\Program Files\Ultraedit\uedit32.exe" & QUOTE & " "
STRCMD2 = " /i=" & QUOTE & "C:\Program Files\Ultraedit\uedit32_new_Instance.ini" & QUOTE



set args = WScript.Arguments
if (args.Count > 1) Then
MeldungRaus "Wrong call"
Elseif (args.Count = 1) Then
fil = QUOTE & args.Item(0) & QUOTE
End If


Set fso = CreateObject("Scripting.FileSystemObject")


strCmd = STRCMD1 & fil & STRCMD2
'msgbox strCmd

set shell = WScript.CreateObject("WScript.Shell")
shell.Run strCmd , 1 , FALSE

wscript.quit

Sub MeldungRaus (strMeld)
wscript.echo strMeld
wscript.quit 1
End Sub
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Open file in New UE Window

Postby Mofi » Fri May 19, 2006 12:14 pm

Hi Bego!

DOS windows are not automatically closing on your computer?

Look in your windows directory for a file named _default.pif. Delete or rename it or click on it with the right mouse button and modify the properties of this DOS shortcut file which is used for all DOS programs without their own *.pif or *.lnk file.

See also the German article Einstellungen für alle DOS-Programme from the great German WinFAQ. A must have for German Windows experts.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4069
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Open file in New UE Window

Postby Bego » Fri May 19, 2006 6:27 pm

Tag Mofi,

doesn't the dos-box stay alive because the call is a syncronous call ?

I renamed the pif to _default.pif.disabled and just startet that test.bat:

@echo off
"c:\program files\tools\editor\ultraedit\uedit32.exe"


Still the dos box is alive until I close UE :-(

With the vbs-solution it certainly works fine. So for me it is just a minor (but nevertheless interesting) question.

Holaraiduliöh :-)

EDIT:
BTW, a cmd /c "c:\program files\tools\editor\ultraedit\uedit32.exe" also does not close the DOS-Box :-/
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Open file in New UE Window

Postby Mofi » Mon May 22, 2006 5:44 am

Hi Bego,

you are right. My batch file works perfect on Win98, but on WinXP the DOS window is not closing until the second instance of UltraEdit is closed. I looked into it and found out that UltraEdit must be started with the start command. So the last line for Win2k/WinXP must be

start "UltraEdit" "path to uedit32.exe\uedit32.exe" "%1" /i="path to uedit32.ini\ue2.ini"

Now the DOS box automatically close after UltraEdit is started when the batch file is executed with a shortcut. But it still does not close when the batch file is executed from within UltraEdit with DOS Command or an user tool, except the Alternate Capture Method is used. UEDOS32.EXE has an influence on closing the DOS window on Win2k/XP. I have not found yet the reason for the wait of the closing DOS window until all called tasks are closed. Maybe I will look into this issue sometime.

However, for Windows 2k/XP there are already 2 working solutions: the Perl script from Tookelso and the VB script from Bego. Thanks, guys!
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4069
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Open file in New UE Window

Postby Bego » Mon May 22, 2006 8:13 am

Hi Mofi,

hey, the start-command really works as expected. Didn't know that command yet. :oops:
Has some interesting issues. look via
Code: Select all
start /?


thx Mofi, rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Open file in New UE Window

Postby Mofi » Mon May 22, 2006 11:22 am

Hi Bego,

if you use the start command in future please note: the window title is not really optional. The start command will interpret the first argument with double quotes always as title. So if anywhere in the whole command double quotes are used, a window title in double quotes must be specified too. This behaviour has taken me 2 hours as I first time run into this issue.

Also note: The start command of Win9x does not have a "title" parameter and there are several other differences.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4069
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Open file in New UE Window

Postby Bego » Mon May 22, 2006 12:08 pm

Hi Mofi,

I saw that too :-/

Many greetz to Redmond for Windows architecture from here ;-)

rds Bego

P.S.: If I didn't mention that before: We'll become Soccer World champions soon. ;-) (I hope I did not perpetrate Fifa-licence-laws :twisted: )
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Open file in New UE Window

Postby deeptinker » Mon May 22, 2006 7:21 pm

I found out a long time ago that if I start UE/UES with a shortcut in Startup, UE/UES comes up and stays up. I can enter DOS commands that invoke UE/UES all day and I get an immediate return.

However, if UE/UES is NOT running, invoking the same command waits until UE/UES has exited before I get the prompt back.

Go figure. :?

Travis
User avatar
deeptinker
Basic User
Basic User
 
Posts: 14
Joined: Fri May 06, 2005 11:00 pm

Next

Return to UltraEdit General Discussion