Welcome!

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

SignUp Now!

@LINES[]?

May
12,845
164
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
 
?

> 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
 

Similar threads

Back
Top