Provide %P%N-Parameter as Pseudo variables for other apps?

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Stefan 2
Junior Member
Junior Member
Posts: 3
Joined: 2007-08-27, 05:57 UTC

Provide %P%N-Parameter as Pseudo variables for other apps?

Post by *Stefan 2 »

Hi Mr. Ghisler,
would you please provide us the Parameters like %P, %N, %O, %L...
as Pseudo-vars as well?

So i can use this information for other tools too.

For example i use an TC-button with PopSel.exe as menu replacement.
h t t p home.mnet-online.de/horst.muc/wpopd.htm
Screen shot : http:// forentmp.lima-city.de/TotalCommander-PopSel.png

I can use e.g. "Notepad.exe %Commander_INI%" to open wincmd.ini with notepad.
But i can not use something like "Notepad.exe %P%N" to open the selected file with notepad.
(i know other ways to do this... this here are examples only)

Would it be a good idea to provide pseudo vars like %P%, %N%, %O%, %L%,... ?
What do you think?

Stefan
Last edited by Stefan 2 on 2007-09-14, 18:14 UTC, edited 2 times in total.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48104
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

WHERE would you need these? In the button bar, you can use them, but only in the "parameters" line, not the "command" line.
Author of Total Commander
https://www.ghisler.com
User avatar
Hacker
Moderator
Moderator
Posts: 13073
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

I assume in the command line in the main window.

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
Stefan 2
Junior Member
Junior Member
Posts: 3
Joined: 2007-08-27, 05:57 UTC

Post by *Stefan 2 »

> WHERE would you need these?

I would like to use this while TC runs with third party application like
* app launchers (e.g. run SyncDir.exe with %P% %T%)
* PopSel as menu replacement (e.g. run Notepad with %P%%O%.txt)
* AutoHotkey/AutoIt (e.g. Loop dir %P%)
* Batch.cmd (e.g. FOR %%i in (%L%) DO xyz %%i)
* use in the command line is a good idea as well

Is an implementation possible?
User avatar
Hacker
Moderator
Moderator
Posts: 13073
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hm, very interesting idea. Support++

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
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hm, will this not mean that we may loose the ability to use for loops inside cmd.exe e.g.?

Inside for-loops you use variable names like %A, %B, %C, ... %Z. Which of these variable names you really need depends on several factors.

Yet, if TC exported its one-letter-variables like %L, %M, %N, %O, %P, %S, %T, I am afraid no for-loop inside cmd.exe might be able to use these variable names any longer, provided the cmd.exe instance was launched by TC.

Karl
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

%A != %A%

++

Icfu
This account is for sale
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

I would be afraid of "Out of environment space" problems after blowing up the environment space - if every pseudo variable will be stored there, this would mean several versions of maybe long path names.

2karlchen
For-loops should be no problem with this, as icfu stated. On command line:

Code: Select all

set L=test
for %L in (*.bat) do @echo %L% %L
set L=
... will list all *.bat, showing "test " in front of their names.

Edit: Tested with Win2k SP4.
Last edited by StatusQuo on 2007-09-16, 14:01 UTC, edited 1 time in total.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Good morning, icfu.
icfu wrote:%A != %A%
I am not as sure as you that cmd.exe will be able to handle the presence of %A and %A% in the same environment.
Yet, I will simply create a batch file and try to use them simultaneously and then report back.

Karl
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi.

OK, looks as if at least under WinXP cmd.exe can tell the two variables named A apart.
@echo off
setlocal enableextensions enabledelayedexpansion

set A=Single_Letter_Variable_A
echo My variable A=%A%

echo Now we will use a for loop using the same variable name.
for %%A in (*.cmd) do echo A=%A% LoopVar=%%A

echo Let us see if my variable still exists
echo My variable A=%A%

endlocal
will yield this output here:

C>tc_env.bat
My variable A=Single_Letter_Variable_A
Now we will use a for loop using the same variable name.
A=Single_Letter_Variable_A LoopVar=adgroupmembers.cmd
A=Single_Letter_Variable_A LoopVar=echo_args.cmd
A=Single_Letter_Variable_A LoopVar=ListAllGroupMembers.cmd
A=Single_Letter_Variable_A LoopVar=remotesvc.cmd
A=Single_Letter_Variable_A LoopVar=remotesvc2.cmd
Let us see if my variable still exists
My variable A=Single_Letter_Variable_A
Regards,
Karl
Last edited by karlchen on 2007-09-15, 22:25 UTC, edited 1 time in total.
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

StatusQuo wrote:I would be afraid of "Out of environment space" problems after blowing up the environment space - ...
This is an DOS-system issue only, not an NT based system issue.


So this improvement could be disabled for DOS based systems.

Or limited to some vars only?
F.ex.:

[Config]
InternVarAsPseudoVar=0 => disable
InternVarAsPseudoVar=1 => enable %P, %N, %O, %E, %T, %M, %L, %l, %F, %f, %D, %d
InternVarAsPseudoVar=2 => enable %P, %N, %T only (recommend for DOS systems )



You can also increase the amount of environment space:

//support.microsoft_dot_com/
Out of environment space

Explanation: The program or command you are trying to run cannot execute because DOS has run out of room in its "environment",
a place where system settings are stored.

Diagnosis: The default environment that DOS uses to hold settings and DOS variables is small--only 256 bytes.
Some programs can cause DOS to run out of space in this area by trying to create more variables that there is no more room for.
A long PROMPT or PATH statement will take up more room.

Recommendation:

* Use fewer environment variables, or shorten the PATH statement in AUTOEXEC.BAT.
* Increase the amount of environment space by adding the following line to your CONFIG.SYS file:
"SHELL=X:\PATH\COMMAND_dot_com /P /E:NNNN" where "X:\PATH" is the directory where the COMMAND_dot_com command interpreter
is located, and NNNN is the new size of the DOS environment area in bytes. Suggested is 512 or 1024
Out of Environment Space Error Message in MS-DOS Programs
View products that this article applies to.
Article ID : 230205
Last Review : January 24, 2007
Revision : 2.3
This article was previously published under Q230205
On This Page
SYMPTOMS
When you attempt to run an MS-DOS program in Windows, you may receive the following error message:
Out of environment space.


CAUSE
This issue can occur if you do not have enough memory in the MS-DOS environment to set an environment variable.


RESOLUTION
To resolve this issue, increase the default environment space available for MS-DOS programs. To do this, use one of the following methods.


Modify the Environment for All MS-DOS Programs
To increase the default environment space for all MS-DOS programs running in Windows, edit the Shell command in the Config.sys file.
To do this, follow these steps:
1. Click Start, and then click Run.
2. In the Open box, type sysedit, and then click OK.
3. Click the Config.sys window.
4. At the beginning of the Shell= line, type REM, and then press the SPACEBAR.

If the Shell= line does not exist, proceed to the next step.
5. Press the HOME key.
6. Type the following line to create a new Shell= line, and then press ENTER:
SHELL=C:\COMMAND_dot_com /E:4096 /P
7. On the File menu, click Save.
8. On the File menu, click Exit.
9. Restart the computer.


Modify the Environment for a Specific MS-DOS Program
To increase the default environment space for a specific MS-DOS program, follow these steps:
1. Right-click the MS-DOS program icon, and then click Properties.
2. Click the Memory tab.
3. In the Initial Environment box, type the number of kilobytes (KB) that the program requires, and then click OK.

NOTE: The maximum amount of memory that you can allocate for an MS-DOS program is 4096 KB.


APPLIES TO
• Microsoft Windows 95
• Microsoft Windows 95
• Microsoft Windows 95
• Microsoft Windows 95
• Microsoft Windows 95
• Microsoft Windows 98 Standard Edition

Back to the top
Keywords:
kberrmsg kbenv kbprb KB230205
"Out of Environment Space" Running Batch File or Command Prompt
View products that this article applies to.
Article ID : 261825
Last Review : January 27, 2007
Revision : 1.2
This article was previously published under Q261825

SYMPTOMS
When you start a batch file or use a command prompt, you may receive the following error message:
Out of environment space


CAUSE
The default space for environment variables is 256 bytes by default. More environment variables are being set than can fit in 256 bytes.


RESOLUTION
To work around this issue, use one of the following methods:


Method 1
1. Right-click the MS-DOS Prompt shortcut, and then click Properties.
2. Click the Memory tab.
3. In the Initial Environment box, set the initial environment size you want (from 256 to 4,096 bytes, in 256-byte increments).
4. Click OK.


Method 2
Edit the Autoexec.bat file to include any environment variables that you need to set, and then reboot the computer.
The changes are incorporated into the registry and the environment variable size is increased.


MORE INFORMATION
Windows Millennium Edition ignores Config.sys statements to increase the environment variable size.

For a list of command-line options, type command_dot_com /?.


APPLIES TO
• Microsoft Windows Millennium Edition


Keywords:
kberrmsg kbprb kbshell KB261825
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Thank you all for your support, BTW :D
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

Stefan2 wrote:
StatusQuo wrote:I would be afraid of "Out of environment space" problems after blowing up the environment space - ...
This is an DOS-system issue only, not an NT based system issue.
Hm, some guys still get this error on XP, maybe due to using old programs there:
(found searching Google for: XP "out of environment space")
It ran fine under 95/98/ME, but I get a "Not enough Space for Environment Error" message (run time error R6009) when trying to run it under XP for him.
In Win2k you can still set the environment size using COMMAND.COM (in %SystemRoot%\system32) - which is used as standard. This can be manually changed to using CMD.EXE in CONFIG.NT (NTCMDPROMPT, explained in standard CONFIG.NT file).

Edit: Just tested this, with NTCMDPROMPT in CONFIG.NT, this seems to be no problem on my current Win2k system: I just successfully created 1024 variables, each 255 bytes long, even more is no problem.
Stefan2 wrote:So this improvement could be disabled
As an option this sounds OK to me.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Maybe it's better to provide pseudo var names like
%TC_P%
%TC_N%
%TC_O%
to be not involved with other var names by mistake?
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Just to bring to mind :D
Post Reply