praat

select a list of objects in praat


I have a list of objects from a for loop and I would like to append them to a list so that I can select and concatenate them. My idea is that the code would function more or less like this:

for stringNumber from 0 to numberOfStrings
    do string stuff...


    tgID = Create TextGrid: tmin, tmax, tier_name$, phone$
    Set interval text: 1, 1, phone$
    # THIS IS WHERE I NEED HELP
    tgList = append: tgID + ", " 

endfor

selectObject: tgList
do ("Concatenate")

Solution

  • You can try this:

    for stringNumber from 0 to numberOfStrings
        # do string stuff...
    
        tgID = Create TextGrid: tmin, tmax, tier_name$, phone$
        Set interval text: 1, 1, phone$
    
        tgList[stringNumber + 1] = tgID
    endfor
    
    selectObject()
    
    for i from 1 to numberOfStrings + 1
        plusObject: tgList[i]
    endfor
    
    Concatenate
    

    selectObject() deselects everything, then plusObject adds the current object to the selection. I am not sure the loop indexes are correct in the selection loop, because you start your loop from 0, and I cannot try your code.