Library functions and line continuations?

#1
Below, it looks like the function "rv" didn't make it from file to memory correctly.
Code:
g:\tc23\library> head /n5 iprocessline.txt
rv {
echo foo ^
bar ^
done
}

g:\tc23\library> library /r iprocessline.txt /u

g:\tc23\library> library /f rv
rv {
done
}
 
#3
LIBRARY /R doesn't support line continuations (it slows things down significantly).

Why would you want to do that?
Why would I want to do what ...

... slow things down significantly? ... I don't want to do that.

... use line continuations? ... because they make editing easier (especially when using TPIPE with several actions).
 
#4
LIBRARY /R doesn't support line continuations (it slows things down significantly).
I did some testing and I'm not sure about the "significantly" part. Using BTMs and a rather outrageous example (one line vs. that line broken into 27 pieces, see below) I see a difference in time of about 1% (to both read it into memory and execute it). I suppose the same could be true of library functions if they allowed continued lines.
Code:
v:\> type fast.btm
1>nul echo abcdefghijklmnopqrstuvwxyz
v:\> type fast2.btm
1>nul echo ^
a^
b^
c^
d^
e^
f^
g^
h^
i^
j^
k^
l^
m^
n^
o^
p^
q^
r^
s^
t^
u^
v^
w^
x^
y^
z

v:\> timer & do i=1 to 10000 ( fast.btm ) & timer
Timer 1 on: 14:03:34
Timer 1 off: 14:03:47  Elapsed: 0:00:13.18

v:\> timer & do i=1 to 10000 ( fast2.btm ) & timer
Timer 1 on: 14:03:47
Timer 1 off: 14:04:00  Elapsed: 0:00:13.34
 

rconn

Administrator
Staff member
May 14, 2008
10,627
97
#5
Your tests are unfortunately not relevant, because you're not measuring what you think you are.

Batch files are (already) read a line at a time; what you're measuring is how long it take to assemble a (really small) line. The LIBRARY /R reads a block at a time and stuffs it in memory, without going through all the line parsing. For a 100 byte file, you won't see any difference; for a 500K file (and yes, there are some users out there with alias & library files that size) it's a sizeable difference.