- May
- 13,123
- 180
Multi-line user-defined functions would be nice ... perhaps in libraries (?).
Here's a rather clumsy way of using a library function (or alias?, or BTM?) to mimmick a UDF without any temp files. These aren't the best of examples but I hope they make a point.
Code:
@my_function {
rem commands
rem ...
rem need a way to specify the value of the function call
}
Here's a rather clumsy way of using a library function (or alias?, or BTM?) to mimmick a UDF without any temp files. These aren't the best of examples but I hope they make a point.
Code:
v:\> function udf
%@exec[@%$]%_this
v:\> library /f factorial
factorial {
set _this=1
do i=2 to %1
set /a _this*=%i
enddo
}
v:\> library /f ncr
ncr {
set _this=%@eval[%@udf[factorial %1] / %@udf[factorial %2] / %@udf[factorial %@eval[%1-%2]]]
}
v:\> echo %@udf[factorial 7]
5040
v:\> echo %@udf[ncr 6 2]
15