Problem with functions @int @decimal and identifying Powershell as a shell.

Nov 16, 2019
3
0
Hello!

I have two problems. One of them is problem with proper functioning of @int and @decimal function. Whenever I try to count integer and decimal part of a number, program skips the decimal point.
Second the program cannot identify Powershell as shell being used. Instead it is identified as cmd.

This is my first time when I use Take Command and I'm writing program, so be understanding :)

 
Last edited:
May 20, 2008
10,498
77
Syracuse, NY, USA
I think @INT and @DECIMAL work as documented. According to the help, ignoring the decimal point is intended.

Second the program cannot identify Powershell as shell being used. Instead it is identified as cmd.
What program fails to identify Powershell? How does it try?
 
Nov 16, 2019
3
0
I tried to use %comspec% variable (which works with Take Command and cmd) to identify in which shell I'am, but I read somewhere that powershell doesn't operate with %comspec%, so I'am stuck now.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,188
72
Albuquerque, NM
prospero.unm.edu
You're checking whether PowerShell is running your .CMD file? I didn't know PowerShell could run .CMD files. I thought it had its own extension?

Regarding your numeric parsing issue, it is possible that your decimal and thousands separator characters are swapped? If you type
Code:
echo %@eval[1/2]
then the second character should be the current decimal separator.
 
Nov 16, 2019
3
0
I checked this :
Echo %@eval[1/2]
and the result was "0,5" , but I still don't know how to fix it :c

Edit. I changed it in options and now functions @int and @decimal works good

I have one more question how to make condition to check whether entered argument is a number?
@numeric function works with letters but with numbers with periods doesn't work
 
Last edited:
May 20, 2008
10,498
77
Syracuse, NY, USA
I have one more question how to make condition to check whether entered argument is a number?
@numeric function works with letters but with numbers with periods doesn't work
Once the decimal character has been set correctly, @NUMERIC should be OK.

Code:
v:\> echo %@int[-22.77]  %@decimal[-22.77]  %@numeric[-22.77]
-22  77  1
 
May 20, 2008
10,498
77
Syracuse, NY, USA
I tried to use %comspec% variable (which works with Take Command and cmd) to identify in which shell I'am, but I read somewhere that powershell doesn't operate with %comspec%, so I'am stuck now.
Powershell doesn't set COMSPEC but it uses it. If you try to execute a .CMD file in Powershell, Powershell will start whatever command interpreter is specified by %COMSPEC% ... maybe TCC, maybe CMD ... it depends on how Powershell was started (where it got COMSPEC from).
 
May 20, 2008
10,498
77
Syracuse, NY, USA
To be more precise, if I start powershell from TCC and (at the Powershell prompt) execute
Code:
V:\> .\pau.cmd
I see this in TaskMgr.

1573930209344.png


If I do the same after starting Powershell from the Start\Run dialog, I see this in TaskMgr.

1573930338404.png
 
May 20, 2008
10,498
77
Syracuse, NY, USA
Yeah, if you attempt to run a .cmd or .bat file from PowerShell, it will run it using cmd.
That depends. If you start Powershell from TCC it will use TCC to run a cmdfile. I think it (or maybe Windows) is using COMSPEC.

Code:
v:\> ver

TCC  25.00.24 x64   Windows 10 [Version 10.0.18362.476]

v:\> powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6


V:\> type .\ver.cmd                                                                                             @echo off
ver

V:\> .\ver.cmd                                                                                                  
TCC  25.00.24 x64   Windows 10 [Version 10.0.18362.476]

V:\>
Code:
v:\> ver

Microsoft Windows [Version 10.0.18362.476]

v:\> powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6


V:\> .\ver.cmd


Microsoft Windows [Version 10.0.18362.476]

V:\>
 
May 20, 2008
10,498
77
Syracuse, NY, USA
You can see the same phenomenon more emphatically. 2-click this cmdfile in explorer.

Code:
v:\> type ver.cmd
@echo off
ver
pause
I imagine it will open in CMD.

Then (at a TCC prompt) issue

Code:
setp %@pid[explorer.exe] comspec=%comspec
That will set Explorer's COMSPEC to TCC and 2-clicking the cmdfile will open it in TCC.