lol, dude, carm down, i was being sarcastic, you did ask for the alias remember.
And you really should use the filter command OR at least switch to the /fopen $fread /fwrite /fclose commands.
I say this becuase, when you read a line in a txt file using $read it reads from the begining of the file to the line number you requested, so reading a 100,000 line file means that line 1 takes a read of 1 line , line 2 takes a read of 2 lines, line 3 takes a read of 3 lines, etc by the time you have read to line 100,000 you have read a total of 5,000,000,000 lines, a large number indeed!
The first codes passed were examples of how to use the filter command, you recieved, files with linenumbers in them becuase that was the 100,000 line file it was using as the source, the alias actually made the file, i think you reported a bug in it that caused it to produce duplicate files, and that was corrected, but even then it was still just going to show you how to use filter, not actually allow you to use it on your file.
Ill explain quickly what the filter command does as i and others used it.
/FILTER -cffr 1 5000 source destination matchtextFilter is designed to search the source (file) for matching lines (if no matchtext is preset then it matches everything so its a copy, however read on)
the -c option tells it to clear the destination (file) before writing to it
the -ff option is needed to tell /filter its using files since it can use windows -w and other things as the source/destination locations
the
-r option this is the big key item this tells /filter to read 2 numbers after the options, and these are the starting line and ending line to search from
so we have
/FILTER -
cleardestination -
file(source) -
file(destination) -
read 1 5000 source(file) destination(file)
as i said above , since there is no matchtext it just copies all them lines
Ill document my code below to let u see what its doing
***** I HAVE CORRECTED A BUG IN THE CODE ALSO ***** The line numbers in the while loop filter were wrong! ooops!
;usage $splitup(source,destination folder/file) * Do not add .txt!
;
alias Splitup {
if (!$isfile($1)) { return -1 } | ; invalid source file
;^ if $1 is not a file exit with a value -1 to indercate bad source filename
;
if (($nofile($2)) && (!$isdir($v1))) { return -2 } | ; invalid destination folder
;^if $2 minus the filename exists (theres a DIR there) then check if the DIR is valid, and if its not then exit with a value -2 to tell you this.
;
if (!$mkfn($nopath($2))) { return -3 } | ; invalid destination file
;^ if after replaceing illegal file characters in the destination filename there turns out to be no filename then exit with a value -3 to tell you this
;
;* If we reach here we can proceed to make the files. *
;
var %i = 1
;^set destination file # fileNNN.txt NNN being 1
;
filter -cffr 1-5000 $+(",$1,") $+(",$nofile($2),$mkfn($nopath($2)),%i,.txt")
;^ do the first filter lines 1 to 5000
;^ I add " " around the source filename since /filter doesnt like the names if spaces are in it
;^ I also do the same to the destination file, but i also get the path $nofile(),
; & then remove illegal filename characters from the filename $mkfn($nopath())
; & finally add the file number %i, and the .txt
;
;A while loop repeats untill the condition becomes false/zero, $filtered is a value saying howmany lines went through the filter
;on first encountering this below, unless the source was empty $filter well have some value (5000) on a 100,000 line file
while ($filtered) {
;^ enter here if some or all of the 5000 lines of the last /filter were copied
;
inc %i
;^ add 1 to the destination file number counter
;
[color:blue]filter -cffr $+($calc(%i * 5000 - 4999),-,$calc(%i * 5000)) $+(",$1,") $+(",$nofile($2),$mkfn($nopath($2)),%i,.txt")
;^ do a filter just like the one above, but this time use (%i * 5000 -4999) for the start line and (%i * 5000) for the end line
;^ ie: if %i was 2 then its (2x5000-4999) to (2x5000) aka lines 5,001 to 10,000
;^ ie: if %i was 3 then its (3x5000-4999) to (3x5000) aka lines 10,001 to 15,000
;[/color]
}
remove $+(",$nofile($2),$mkfn($nopath($2)),%i,.txt")
;^ since the while loop exits only when the last filter had no lines copied (ie its line numbers are beyond the end of the file)
;^ I must delete this last file I created, as its empty anyway
;
dec %i
;^ lastly reduce the destination file number counter to be the last file actually written
;
return %i
;^ exit with this value, so u know how many files were made
;
}