Beginner question Lua .Function as keybinbing

beginner question here .
as an example i’m using simple but useful "Beatslaughter’s ClearSelection tool.

_AUTO_RELOAD_DEBUG = true

renoise.tool():add_keybinding {
name = “Pattern Editor:Selection:Clear”,
invoke = function()
renoise.song().selection_in_pattern = {}
end
}

renoise.tool():add_keybinding {
name = “Phrase Editor:Selection:Clear”,
invoke = function()
renoise.song().selection_in_phrase = {}
end
}

it works of course as it should . you assign key command to it and it clears selection as per design .
i experimented by substituding renoise.song().selection_in_pattern = {} with renoise.song():redo()
and it workes but if i substitude renoise.song().selection_in_pattern = {} with any other function
for example renoise.song():delete_track_at(index) i get error in LuaTestPad below

*** main.lua:6: variable ‘index’ is not declared
*** stack traceback:
*** [C]: in function ‘_error’
*** [string “local mt = getmetatable(_G)…”]:29: in function <[string “local mt = getmetatable(_G)…”]:24>
*** main.lua:6: in function main.lua:5

you can test it yourself ! why is that happening ?

Thank You
GC

What is setting the value of index? Is it a valid value for the current song?

could you give example of how it should be by correcting code below ?
song with say 3 tracks and i just want to delete 1 track out of 3 .
if my question makes no sense then why ? whatever your answer would be it will push me further ahead

_AUTO_RELOAD_DEBUG = true

renoise.tool():add_keybinding {
name = “Pattern Editor:Selection:Clear”,
invoke = function()
renoise.song():delete_track_at(index)
end
}