- Aug
- 2,843
- 150
I wanted to calculate the start line,
given a line number.
If the line number subtract 3 is less than 1,
then the start line is 1.
Here's how I did this using TCC internal functions;
The .NET Framework provides another solution,
using the .NET Framework Math class,
which can be accessed from TCC;
Ref: Math.Max Method (System)
Joe
given a line number.
If the line number subtract 3 is less than 1,
then the start line is 1.
Here's how I did this using TCC internal functions;
Code:
R:\>set linenumber=1422
R:\>set startLine=%@max[1,%@eval[%LineNumber-3]]
R:\>echo %startline
1419
R:\>set linenumber=2
R:\>set startLine=%@max[1,%@eval[%LineNumber-3]]
R:\>echo %startline
1
The .NET Framework provides another solution,
using the .NET Framework Math class,
which can be accessed from TCC;
Code:
R:\>which psc
psc is an alias : pshell /s %@quote[%$]
R:\>set linenumber=1422
R:\>psc $env:startLine = [Math]::Max(1, $env:LineNumber - 3)
R:\>echo %startline
1419
R:\>set linenumber=2
R:\>psc $env:startLine = [Math]::Max(1, $env:LineNumber - 3)
R:\>echo %startline
1
Ref: Math.Max Method (System)
Joe