Here's a version that doesn't create an extra text file, which is very fast (600 ms on my system), and yet works entirely different.
That's one of the things I like the most about programming, that you can achieve the same thing with different tools.
; Usage: $split(source filepath, destionationfile) without .txt
;
; Example: //echo -a $split($mircdir\test\bigfile.txt, c:\files\test)
;
; will output text files like test1.txt, test2.txt, etc.
;
alias split {
if !$isfile($1) || !$isdir($nofile($2)) || !$mkfn($nopath($2)) { return Error }
window -h @@
loadbuf -r @@ " $+ $1"
var %a = 0, %b = $+(",$nofile($2),$mkfn($nopath($2)))
while $line(@@,1) != $null {
inc %a
savebuf 1-5000 @@ $+(%b,%a,.txt")
dline @@ 1-5000
}
close -@ @@
return %a
}