#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 Changed 17 months ago by lwc
comment:3 Changed 17 months ago by Jpm
I thing you just need to use the OPt("ExpandEnvStrings", 1)) which allow such expansion
comment:4 Changed 17 months ago by Jpm
- Milestone set to 3.3.16.1
comment:5 Changed 17 months ago by TicketCleanup
- Milestone 3.3.16.1 deleted
Automatic ticket cleanup.
comment:6 Changed 16 months ago by Jpm
- Resolution set to Works For Me
- Status changed from new to closed
As I said use Opt()
comment:7 Changed 14 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.
Please change to the latest version (currently v3.3.16.1).