Opened 7 months ago

Closed 6 months ago

Last modified 4 months ago

#3964 closed Feature Request (Works For Me)

Allow EnvGet to support whole strings like _WinAPI_ExpandEnvironmentStrings

Reported by: lwc Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: environment Cc:


While _WinAPI_ExpandEnvironmentStrings supports whole strings (but requires an include), EnvGet only allows to input a specific environment variable and even then without percents.

I don't presume to retroactively change that, but what about accepting a secondary optional parameter called $full? That is, Func EnvGet($envvariable, $full=False) whereas $full is optional and by default False.

But if $full is True then just do something like (only internally):

If $Full Then
  return Execute("'" & StringRegExpReplace($envvariable, "%(\w+)%",  "' & EnvGet('$1') & '" ) & "'")

This will allow to support commands like ConsoleWrite(EnvGet("My temp variables are %temp% and %tmp%", true)).

Attachments (0)

Change History (7)

comment:1 Changed 7 months ago by lwc

Please change to the latest version (currently v3.3.16.1).

comment:2 Changed 7 months ago by TicketCleanup

  • Version deleted

Automatic ticket cleanup.

comment:3 Changed 7 months ago by Jpm

I thing you just need to use the OPt("ExpandEnvStrings", 1)) which allow such expansion

Last edited 7 months ago by Jpm (previous) (diff)

comment:4 Changed 7 months ago by Jpm

  • Milestone set to

comment:5 Changed 7 months ago by TicketCleanup

  • Milestone deleted

Automatic ticket cleanup.

comment:6 Changed 6 months ago by Jpm

  • Resolution set to Works For Me
  • Status changed from new to closed

As I said use Opt()

comment:7 Changed 4 months ago by lwc

Please don't close like that. In some cases one may want to preserve % in strings and only sometimes convert them. For example, when saving your script's settings you might want to save a parameter called $path as literally %appdata% instead of hardcoding it due to Opt(), so it will fail in another computer.

Why not just supporting the aforementioned $full variable?

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.