Get last lines : str_getTail for AHK v2

Post your working scripts, libraries and tools.
Gotjek
Posts: 18
Joined: 11 Aug 2022, 11:01

Get last lines : str_getTail for AHK v2

Post by Gotjek » 23 Aug 2022, 11:00

Hi !

I wanted to get the last lines of a file or string. I searched the forum and found this post by Tuncay.
I adapted it for AHK v2 (with help). As I am some AHK noob, it may not be perfect. I hope it will be useful !

Code: Select all

str_getTail(input_str, last_lines := 1)
{
    position := InStr(input_str, "`n",, -1, -last_lines)
    If position != 0{
        output := SubStr(input_str, position)
        output := SubStr(output, InStr(output,"`n") + 1)
    }Else
        output := input_str
    Return output
}

Return to “Scripts and Functions (v2)”