@LINES[]?

May 20, 2008
11,400
99
Syracuse, NY, USA
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
12,345
150
?

> 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
Thread starter Title Forum Replies Date
vefatica Continued lines (^) in a library routine? Support 5
R Lines between COMMENT & ENDCOMMENT not ignored Support 7
A TCMD - Dir Command puts out blank lines? Support 16
T FFind - can we display n number of lines after the find? Support 2
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
JohnQSmith Weird DIR output (missing lines) Support 1
fpefpe Documentation Comment lines? Support 2
nickles Fixed Executing long command lines in a batch generates file name errors Support 16
B %@lines doesn't count last line without cr/lf at eof Support 1
nikbackm How to? Find duplicate lines in text file Support 0
S Documentation HELP nit: @LINES Support 5
B Select and run lines from Command Input panel? Support 1
D WAD New envars for @LINES are not hidden Support 8
T Documentation @LINE[CON,n] @LINES[CON] not documented (bug?) Support 4
M How to? Parsing lines containing double quotes... Support 3
Stefano Piccardi echoerr truncates long lines Support 9
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
samintz How to? Pull out multiple matching lines Support 5
W Copy+Paste without breaking long lines as default? Support 1
L "for" in multiple lines Support 2
vefatica @LINES, long lines, TCC disappears Support 7
D Blank lines in jpstree.idx Support 3
T @Word from Lines with Pipes Support 3
J Extra blank lines during paste Support 6
vefatica How many lines are in this file? Support 17
nikbackm Trim last N lines from a file Support 6
T How do you echo lines with special characters to file? Support 4
B @lines: first line in the file is numbered 1 Support 0
R Reading an Unicode file with more than 8191 lines Support 1

Similar threads