[NTG-context] problem with lua io.lines

Henning Hraban Ramm texml at fiee.net
Wed Aug 14 19:02:24 CEST 2013


Am 2013-08-14 um 21:00 schrieb Hans Hagen <pragma at wxs.nl>:

>>    for ts in io.lines(string.gsub(name, '%.pdf$', '-systems.count')) do
>>      syco = ts*1
>>    end
> 
> well, you probably were lucky before: string.gsub returns multiple values so io.lines get a second argument that limits the length of what gets returned

Thank you, didn't know that!

> local myfile = "myfile.txt"
> 
> for myline in io.lines(myfile,2) do
>    logs.report("test",myline)
> end
> 
> so you need:
> 
>  io.lines((string.gsub(name, '%.pdf$', '-systems.count')))
> 
> or
> 
>  local name = string.gsub(name, '%.pdf$', '-systems.count')
> 
>  io.lines(name)

Great, that works!

> or maybe better:
> 
>  io.lines(file.replacesuffix(name,'-systems.count'))


No, that doesn't work, because the dot stays, so I get foobar.-systems.count


Greetlings, Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)



More information about the ntg-context mailing list