Environment variables in buttons or user command parameters?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
funkymonk
Senior Member
Senior Member
Posts: 493
Joined: 2013-12-04, 09:56 UTC

Environment variables in buttons or user command parameters?

Post by *funkymonk »

Hi!

Is there a way to use environment variables in buttons or user command parameters?

The following user command zips TC into a file in the active panel:

Code: Select all

[em_BackupTC]
cmd=ZIPFROMLIST -9 "totalcmd%TC_VERSION%.zip" 
param="c:\pathToLstFiles\tcbackup.lst"
button=%COMMANDER_EXE%,7
menu=Backup Total Commander Directory as ZIP File (into active panel)
The zip filename shows the TC version since env variables are supported in the cmd line.
However, the param line requires the source list file to be hard coded (c:\pathToLstFiles).
This line does not work:

Code: Select all

param="%COMMANDER_PATH%\tcbackup.lst"
Thus: Is there a way to use environment variables in buttons or user command parameters?

---

Side notes:
  1. Code: Select all

    cmd=ZIPFROMLIST -9 "totalcmd%TC_VERSION%.zip" "%COMMANDER_PATH%\tcbackup.lst"
    
    would be very convenient. However, this does not work since ZIPFROMLIST expects the list file as param.
  2. tcbackup.lst simply contains one line:

    Code: Select all

    %COMMANDER_PATH%
    
    This is very convenient.
    In fact, such lst files can be used to create backup profiles for many situations/folders.

    --> It would be great to have an env variable that points to the folder containing these lst files...
User avatar
petermad
Power Member
Power Member
Posts: 16027
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Environment variables in buttons or user command parameters?

Post by *petermad »

Just use double % for environment variablee in the param field - like "%%COMMANDER_PATH%%\tcbackup.lst"
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
funkymonk
Senior Member
Senior Member
Posts: 493
Joined: 2013-12-04, 09:56 UTC

Re: Environment variables in buttons or user command parameters?

Post by *funkymonk »

petermad wrote: 2022-08-23, 07:51 UTC Just use double % for environment variablee in the param field - like "%%COMMANDER_PATH%%\tcbackup.lst"
Sorry, that does not work.

%% collapses to a single % and the env var is not expanded.

What I get with the suggested param is an error message:

File not found:
%COMMANDER_PATH%\tcbackup.lst
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Environment variables in buttons or user command parameters?

Post by *Hacker »

funkymonk,
You need to put it into the Parameters field. Or you can leave it in the Command field but only use a single % sign.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
white
Power Member
Power Member
Posts: 5785
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Environment variables in buttons or user command parameters?

Post by *white »

funkymonk wrote: 2022-08-23, 12:20 UTC Sorry, that does not work.

%% collapses to a single % and the env var is not expanded.
Correct, I don't think the ZIPFROMLIST commands supports environment variables anywhere.
User avatar
funkymonk
Senior Member
Senior Member
Posts: 493
Joined: 2013-12-04, 09:56 UTC

Re: Environment variables in buttons or user command parameters?

Post by *funkymonk »

Hacker wrote: 2022-08-23, 13:20 UTC funkymonk,
You need to put it into the Parameters field. Or you can leave it in the Command field but only use a single % sign.

HTH
Roman
ZIPFROMLIST does not support this parameter in the cmd string. It must go to the param string (according to the help and after some try and error).
white wrote: 2022-08-23, 14:10 UTC
funkymonk wrote: 2022-08-23, 12:20 UTC Sorry, that does not work.

%% collapses to a single % and the env var is not expanded.
Correct, I don't think the ZIPFROMLIST commands supports environment variables anywhere.
Seems so. In fact, it seems that the entire param string (independent from the cmd string) does not support the expansion of environment variables.
The help also does not mention support for env variables in the param string.

@ghisler Is there any support for that?
User avatar
white
Power Member
Power Member
Posts: 5785
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Environment variables in buttons or user command parameters?

Post by *white »

white wrote: 2022-08-23, 14:10 UTC Correct, I don't think the ZIPFROMLIST commands supports environment variables anywhere.
It does work in Command field.

This works:

Code: Select all

TOTALCMD#BAR#DATA
zipfromlist "%temp%\tctest123.zip"
%UF
wcmicons.dll,60


0
-1
User avatar
funkymonk
Senior Member
Senior Member
Posts: 493
Joined: 2013-12-04, 09:56 UTC

Re: Environment variables in buttons or user command parameters?

Post by *funkymonk »

white wrote: 2022-08-23, 14:56 UTC
white wrote: 2022-08-23, 14:10 UTC Correct, I don't think the ZIPFROMLIST commands supports environment variables anywhere.
It does work in Command field.

This works:

Code: Select all

TOTALCMD#BAR#DATA
zipfromlist "%temp%\tctest123.zip"
%UF
wcmicons.dll,60


0
-1
Yes, this works. But this is not the point.
The list file (%UF in your case) cannot be specified in the cmd string. It has to be a param. And in param there is no expansion of env variables (%UF is no env variable)...
User avatar
petermad
Power Member
Power Member
Posts: 16027
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Environment variables in buttons or user command parameters?

Post by *petermad »

2funkymonk

This command works for me:

Code: Select all

[em_BackupTC]
cmd=ZIPFROMLIST -9 "totalcmd%TC_VERSION%.zip"
param=tcbackup.lst
path=%COMMANDER_PATH%
button=%COMMANDER_EXE%,7
menu=Backup Total Commander Directory as ZIP File (into active panel)
But if you are not in %COMMANDER_PATH% when you execute the command, the file names in tcbackup.lst must be saved with full path - you can use %COMMANDER_PATH% in the tcbackup.lst though.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
funkymonk
Senior Member
Senior Member
Posts: 493
Joined: 2013-12-04, 09:56 UTC

Re: Environment variables in buttons or user command parameters?

Post by *funkymonk »

2petermad

Good idea. The "workaround" with the env var in path works for this use case. Thank you.

Still, I would highly appreciate support for env vars in the param string...

Should we move this request into the suggestions board?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50475
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Environment variables in buttons or user command parameters?

Post by *ghisler(Author) »

Still, I would highly appreciate support for env vars in the param string...
Unfortunately this would clash with parameter fields, which use a single % followed by one or more characters, like %P%N. Here TC couldn't know whether %P% is an environment variable or %P and %N are separate parameters.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5785
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Environment variables in buttons or user command parameters?

Post by *white »

2ghisler(Author)
How about solving it by accepting this syntax: %{COMMANDER_PATH}%
Post Reply