function main() cprintf(cli.yellow,"Starting Main Function \n") Renumber("filename") -- Place the name of your file in here end function Renumber(waypt_file) cprintf(cli.yellow,"Starting Renumber Function \n") if waypt_file == nil then cprintf(cli.red,"No file name. Usage Renumber(\"YourWaypointFile\")\nDo not the path or extension.\nThis script creates a renumbered copy.\n\n"); return false end local filenameIn = getExecutionPath() .. "/waypoints/" .. waypt_file .. ".xml"; local filenameOut = getExecutionPath() .. "/waypoints/" .. waypt_file .. "_renum.xml"; local fileIn, err = io.open(filenameIn, "r"); local fileOut, err = io.open(filenameOut, "w+"); local newNumString = ""; local padding = ""; local startVal1 = 0; local startVal2 = 0; local endVal1 = 0; local endVal2 = 0; local line = ""; local lineNumber = 1; local replCount = 0; if fileIn and fileOut then for line in fileIn:lines() do startVal1, endVal1 = string.find(line, "", 1, true); newNumString = ""; line = string.sub(line, 1, startVal1-1) .. newNumString .. string.sub(line, endVal2 + 1, -1) lineNumber = lineNumber + 1; end fileOut:write(line .. "\n"); end else cprintf(cli.red,"Couldn't open/create the files. Usage Renumber(\"YourWaypointFile\")\nDo not the path or extension.\nThis script creates a renumbered copy.\n\n"); return false end fileIn:close(); fileOut:close(); cprintf(cli.green,"Done. New file is " .. waypt_file .. "_renum.xml\n"); end startMacro(main,true);