Modify

Opened 3 years ago

Closed 3 years ago

Last modified 2 years 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:

Description

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') & '" ) & "'")
EndIf

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

Attachments (0)

Change History (7)

comment:1 by lwc, 3 years ago

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

comment:2 by TicketCleanup, 3 years ago

Version: 3.3.14.0

Automatic ticket cleanup.

comment:3 by J-Paul Mesnage, 3 years ago

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

Last edited 3 years ago by J-Paul Mesnage (previous) (diff)

comment:4 by J-Paul Mesnage, 3 years ago

Milestone: 3.3.16.1

comment:5 by TicketCleanup, 3 years ago

Milestone: 3.3.16.1

Automatic ticket cleanup.

comment:6 by J-Paul Mesnage, 3 years ago

Resolution: Works For Me
Status: newclosed

As I said use Opt()

comment:7 by lwc, 2 years ago

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?

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.