; $1 = filename, $2 = linenumber
alias readline {
; check file exists
if (!$isfile($1)) return
; check for a valid line number.
if ($2 !isnum 1-) return
; create a unique name
var %name = $+(txt,$ticks)
; open text file
.fopen %name $qt($1)
; check for errors
if ($fopen(%name).err) goto error
; jump to line we want.
.fseek -l %name $2
; check for errors
if ($fopen(%name).err) goto error
; check for end of file
if ($fopen(%name).eof) goto error
; get text line
set -ln %txt $fread(%name)
; clean up
:error
.fclose %name
; return requested line. Keeping spaces etc..
returnex %txt
}
alias indent_test {
var %f = versions.txt, %line = 96
; line 96 is: [space][space][space]options.
; which is 11 characters
echo Length should be: 11
echo read: $len($read(%f,nt,%line))
echo fopen: $len($readline(%f,%line))
set -ln %ok $readline(%f,%line)
echo fopen2: $len(%ok)
}