System environment variables in macros?

Help with writing and playing macros

System environment variables in macros?

Postby bobh » Sat Jun 25, 2005 10:04 am

Is it possible to use an environment variable in a macro? I know that I can do this in a custom tool, but it would be nice to have in a macro...
User avatar
bobh
Advanced User
Advanced User
 
Posts: 59
Joined: Tue Dec 28, 2004 12:00 am

Re: System environment variables in macros?

Postby Mofi » Sat May 27, 2006 1:33 pm

You will have thought it already by yourself - no!

Not even at the Open and SaveAs commands although environment variables can be used in the "File Open" and "Save As" dialogs.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3937
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: System environment variables in macros?

Postby sven » Mon May 24, 2010 2:37 am

Hi, I would like to include the value of windows system variables in an uedit maco (i.e. "username") for documentation of last changes in a file. The macro language has time and date functions, but I don't find hints for including external variables.
Or ist is necessary to change from macro to scripting?
Many thanks in advance
Sven
sven
Newbie
 
Posts: 2
Joined: Mon May 24, 2010 2:28 am

Re: System environment variables in macros?

Postby Mofi » Mon May 24, 2010 9:31 am

UltraEdit macros are not Visual Basic scripts. You can't access Windows environment variables from within an UltraEdit macro. All macro commands are listed in the macro editor or on UltraEdit help page Edit Macro command. That's it, that's all you have.

There is only one command which gives you the possibility to access something outside UltraEdit, the command RunTool to call one of the 25 user or 25 project tools by name. But that user tool must be configured first from the Advanced menu.

See How to run ANY console or Windows application from within an UE script/macro? for a general solution to call the command echo %username% from within a macro.

Or you configure a user tool just for getting the user name as follows:

On tab Command:

Menu Item Name: Get User Name (for example)
Command Line: echo %username%
Working Directory: (let it empty)
Toolbar bitmap/icon: (let it empty or browse to a BMP or ICO file)

On tab Options:

Program Type: Dos Program
Save Active File: unchecked
Save all files first: unchecked

On tab Output:

Command Output: Output to List Box
Show DOS Box: unchecked
Capture Output: checked
Replace selected text with: Captured Output

With that user tool the macro could position the cursor in the active file where the user name should be inserted and then use the command

RunTool "Get User Name"
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3937
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: System environment variables in macros?

Postby sven » Mon May 24, 2010 12:18 pm

Hi Mofi,

many thanks for your solution. Just great! And I will study the link you gave for a good bit of learning more of that.

Thank you very much
Sven
sven
Newbie
 
Posts: 2
Joined: Mon May 24, 2010 2:28 am


Return to Macros

cron