Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

CMath and the @PSHELL function

Aug
2,320
111
Hello @Charles Dye,
I cannot get the @PSHELL function to work with the CMath feature of the EditKeys plugin.

Code:
R:\>which @pshell64
@pshell64 is a user-defined variable function (%@strip[%@char[13 10],%@pshell[%$]])

R:\>pshell /s "$a=60"

R:\>pshell /s $a
60

R:\>:%@pshell64[$a]
%@pshell64[$a] = 60

R:\>:%@pshell[$a]
TCC: Syntax error "60
"

I'm trying a solution that you gave me a while back for working with @EVAL,
but it does not work in this instance.

Joe
 
It looks to me like the @PSHELL64[] approach is working, for both of us. It's just when we don't strip off the trailing EOL that things go awry.

I could add a hack to ignore carriage returns and line feeds; is that what you're looking for?
 
Yes, ignoring carriage returns and line feeds should solve the problem.

In the meantime, this works for me;

Code:
R:\>which psc
psc is an alias : pshell /s %$

R:\>:%{psc $a}
%{psc $a} = 60

R:\>:%{psc $a}+10
%{psc $a}+10 = 70

Joe
 
I've uploaded a new build; let me know whether it works for you.
 
Thanks @Charles Dye, works for me.
Code:
@setlocal
@echo off
pshell /s "$a = New-TimeSpan $(Get-Date) $(Get-Date -month 11 -day 15 -year 1960 -hour 23 -minute 30)"
pshell /s $a

text > con:
COMMENT These work with no errors using the CMath feature of 
        the EditKeys plugin 2024-11-09
:%@pshell[$a.TotalDays]
:%@pshell[$a.TotalDays*-1]
:%@pshell[$a.TotalDays*-1] / 365.25
ENDCOMMENT
endtext

endlocal

Output
Code:
R:\>test.btm


Days              : -23369
Hours             : -17
Minutes           : -21
Seconds           : -59
Milliseconds      : -984
Ticks             : -20191441199849094
TotalDays         : -23369.7236109365
TotalHours        : -560873.366662475
TotalMinutes      : -33652401.9997485
TotalSeconds      : -2019144119.98491
TotalMilliseconds : -2019144119984.91



COMMENT These work with no errors using the CMath feature of
        the EditKeys plugin 2024-11-09
:%@pshell[$a.TotalDays]
:%@pshell[$a.TotalDays*-1]
:%@pshell[$a.TotalDays*-1] / 365.25
ENDCOMMENT

Joe
 
Back
Top