@LINES[]?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
Unlike many other variable functions that give info about a file, @LINES[] screws up the command it's embedded in when the file doesn't exist. Perhaps it could give the string "-2" in that case.

Code:
v:\> if "%@crc32[idontexist]" eq "" echo foo

v:\> if "%@md5[idontexist]" eq "" echo foo

v:\> if "%@filesize[idontexist]" eq "" echo foo

v:\> if "%@lines[idontexist]" eq "" echo foo
TCC: (Sys) The system cannot find the file specified.
 "%@lines[idontexist]"
Usage : IF [/I] [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] command
 

rconn

Administrator
Staff member
May 14, 2008
10,103
85
#2
?

> Unlike many other variable functions that give info about a file,
> @LINES[] screws up the command it's embedded in when the file doesn't
> exist. Perhaps it could give the string "-2" in that case.
The error is being returned four levels down in the parser; @LINES has no
way of knowing what failed or why.

I'd recommend testing for the existence of the file rather than relying on a
variable function error message. Since there are several hundred functions
with a wide variety of possible errors, there's no way for the TCC variable
expansion to deliver detailed error messages without adding a mini-parser to
every function. And significantly degrading the performance. And VASTLY
increasing the code size!

Rex Conn
JP Software