Skip to main content
dublove
Legend
October 26, 2026
Question

How do I know which line the first row of the current column is in the article?

Hello everyone.

If I select some rows, the first line of the current column is this:
curLine0=app.selection[0].textColumns[0].lines[0];
Is there a simple way to know which line curLine0 is in the story?

Do I still need to count the characters?

 

    1 reply

    Community Expert
    October 26, 2026

    use the following function, it will take as an input the line object and give back the line number in the parentStory.

    function getLineNoInParentStory(ln) {
    var parStory = ln.parentStory
    var idx = ln.index
    var idxList = parStory.lines.everyItem().index
    var lidx
    for(var i = 0 ; i < idxList.length ; i++) {
    if(idxList[i] == idx) {
    return parseInt(i) + 1

    }
    }
    return null
    }

    You call it like the

    var lineNo = getLineNoInParentStory(curLine0)

     

    Translate
    -Manan