Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Phred
Senior Member
Senior Member
Posts: 375
Joined: 2009-06-16, 15:24 UTC
Location: SEAu

Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *Phred »

I'd like to be able to use a configuration that has a set of tabs that can be used relatively.
I'd like to be able to use a particular ini that references a user's folder branch at each invocation, irrespective of which user is current.
I see that virtual folders can be saved in an ini, e.g. \\desktop\*.* - but that, say,
c:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\ cannot.

I note that %USERNAME% can be inserted directly into the folder name line, but TC immediately translates that into the current username.

I also note that %USERNAME%, put directly into a locked tab in an ini, isn't interpreted correctly when TC is invoked. It would open a tab in the example above as:
c:\Users\

Save relative tabs?
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *ghisler(Author) »

You can use environment variables in tabs (sections [lefttabs] and [righttabs]), but the variables get translated to their current value. But you can turn off saving of tabs on exit to preserve them.
Author of Total Commander
https://www.ghisler.com
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *AntonyD »

but the variables get translated to their current value
and what the heavy reason is for this action?
#146217 personal license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *ghisler(Author) »

The reason is that %USERNAME% is a perfectly valid directory name which you can create with F7. However, Windows functions like CreateFile do not work when you pass environment variables to them - they will look for the real %USERNAME% and not for the translated name. This has to be done by the program beforehand.
Author of Total Commander
https://www.ghisler.com
User avatar
Phred
Senior Member
Senior Member
Posts: 375
Joined: 2009-06-16, 15:24 UTC
Location: SEAu

Re: Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *Phred »

ghisler(Author) wrote: 2022-07-05, 06:47 UTC You can use environment variables in tabs (sections [lefttabs] and [righttabs]), but the variables get translated to their current value. But you can turn off saving of tabs on exit to preserve them.
That's a shame that they get translated without reversion for the reasons described below. It does makes parameterising configurations less flexible.

I see that environment variables can be preserved by "turn[ing] off saving of tabs on exit" in Options | Configuration | Operation | 'Save on exit' and leaving Directories unticked.
This seems to me to leave TC sitting on a precarious edge since Options | 'Save settings' (that I have in a button and use frequently (cm_ConfigSaveSettings)) would be a verboten choice.

From another angle, having seen references to loading buttonbar buttons with folder directives, would it be possible to load a button with multiple tabs in both left and right panels (after closing all extant)?
Incorporating literal (translatable) environment variable text expressions, temporary though that would be.
A second button could be used for loading back the ini's original default set.
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *AntonyD »

This has to be done by the program beforehand.
Ok, looks like ExpandEnvironmentStrings(...) or ExpandEnvironmentStringsForUser(...) func is already in use ;)
BUT the question is just little bit changed - and not more - why you put at INI file ALREADY preprocessed strings?
Why not process them after reading parametrized strings from INI?
#146217 personal license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Can TC Hold Virtual Names or Environment Variables in Tabs Configurations?

Post by *ghisler(Author) »

I only put them in the ini on exit.
When I load from ini, I process them so the user can change directories, otherwise the user can't change directories. For example, take variable %USERPROFILE%, it translates to c:\users\accountname. If I kept %USERPROFILE%, the user couldn't go up to c:\users. This is just one of many possible problems.
Author of Total Commander
https://www.ghisler.com
Post Reply