Problem with running script from command line in DOS batch file

Help with writing and running scripts

Problem with running script from command line in DOS batch file

Postby Efcis » Thu Aug 13, 2009 6:22 pm

Hi!

I'm facing some issues and maybe a bug related to the use of the command line with UE.

  1. To open a file and position the cursor on a specific line, I need to enclose the *whole* command into quotes if the filename or/and the path contains spaces.

    Examples :

    Code: Select all
    uedit32 "c:\first dir\second dir\file.txt/10"

    works. But

    Code: Select all
    uedit32 "c:\first dir\second dir\file.txt"/10

    doesn't work (well, it opens the file, but I get an annoying error message).

    It sounds more logical to me to use the second syntax, as the command line options should not be enclosed by quotes.


  2. I also tried to use a script as described in Run a macro or script from the command line with no luck :-(

    I also tried zillions of quotes combinations, unsuccessfully. And even a very simple :

    Code: Select all
    uedit32 c:\temp.txt /s="c:\testOutputUE.js"
    or
    Code: Select all
    uedit32 c:\temp.txt /s=c:\testOutputUE.js

    doesn't work for me - It is *very* similar to one of the examples of the web page mentioned above.
Did I miss something?

Thanks and regards
Efcis
Newbie
 
Posts: 2
Joined: Thu Aug 13, 2009 5:05 pm

Re: Problem with running script from command line in DOS batch file

Postby Mofi » Fri Aug 14, 2009 12:44 am

You must use "c:\first dir\second dir\file.txt/10" because the argument is filename/line number as documented in help of UltraEdit. When an argument contains spaces you have to enclose it in spaces so that Windows passes this argument as one string to the called application.

Second your command line to call UltraEdit and execute the script surely works, but only when no UltraEdit is currently open or when configuration setting Allow multiple instances is enabled.

Use uedit32 /fni c:\temp.txt /s="c:\testOutputUE.js" and starting UltraEdit with loading the file and executing the script always works, independent if one or more instances of UltraEdit are already open and independent of the configuration settings. For details why /fni must be used see Always get error message when running a macro/script via command line parameter.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4051
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Problem with running script from command line in DOS batch file

Postby Efcis » Fri Aug 14, 2009 5:36 am

Hi Grand Master Mofi ;-)

Thanks for your prompt reply and the complete explanations.

A final question : Is there an easy way to send text to the output window with the command line? For now, the only way I found was to use a temporary text file and a script to copy its content to the output window - not very efficient, to say the least. Is there a "/o "Blahblah"" hidden feature ? ;-)

Actually, I wanted to use UE as a "helper editor" for my own program that requires editing (it works), and displaying an output status.

Thanks and regards
Efcis
Newbie
 
Posts: 2
Joined: Thu Aug 13, 2009 5:05 pm

Re: Problem with running script from command line in DOS batch file

Postby Mofi » Fri Aug 14, 2009 6:32 am

I don't know about a method to call UltraEdit and tell UE to load the content of a file to its output window. You could write an email with the request for an enhancement of the command line parameters to be able to specify for example /ow,1="file to show in output window" on the command line. ,1 would be an optional parameter for UEStudio which has 4 output windows and therefore it would be good if on the command line the number 1-4 for the output window to use could be specified too.

A quick method to get content of a file into the output window is to configure a user tool with the command line type "name of the file", specify to capture the output of this DOS user tool to the output window in the tool options, and write a script or macro which simply just calls this user tool. Of course that requires also the usage of /s= or /m= and therefore requires /fni.

To make the file name variable, the user tool could have the command line type "%f", the file with the content for the output window is specified as file to open in UltraEdit and the macro/script closes this file after executing the tool.

The last variant I can suggest is to use a fixed file name and a macro is created which calls the user tool and then closes the file with the definite name. This macro having the code

IfNameIs "Name of file with content for output window without path and extension"
RunTool "case-sensitive name of the tool"
CloseFile NoSave
EndIf


is configured to be executed on every file load. Now it would be possible to just call uedit32.exe with the file and it should be loaded into the output window. That would work without /m, /s and /fni and therefore also when UltraEdit is already running.

Maybe there is an interface for applications using UltraEdit as editor to write something directly to its output window. If there is such an interface, it is not documented public. Contact IDM support by email and ask if such an interface exist. UltraEdit is used in some other applications as editor.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4051
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts