Nothing too complicated, there are just a few changes to make.
For
FileReadLine
, the line count starts a1
and not0
unlike other languages. So trying to read line0
,FileReadLine
will essentially "read" nothing.For the
mod()
function, the documentation says :If the second parameter is zero, the function yields a blank result (empty string).
Logically, when the script starts, and
size
is0
,FileReadLine
will try to read line number "blank". As I recall, "blank" is not a number.mod(%Line%-1, size)
is an expression. That means, that everything is parsed as an expression here.Mod()
will return its calculated value like normal, if successful (consider #2). if we consider%Line%-1
, parsed as expression, here is what we'll have :
Let's say we havevar:=4
andvar_b:=(%var%-1)
. One might think thatvar_b
would be equal to3
, but that is false. Invar_b:=(%var%-1)
, the contents ofvar
will be evaluated as the name of a variable and then the contents of that variable. This means that it will take4
and evaluate it as the variable named4
and NOT the value4
. Unless the variable4
has been set, it will return "blank". As I recall (again), "blank" is not a number. In this case, I imagine the intended expression wasmod(Line-1, size)
.