--Anonycodes Program Updater function setup() --[[ --instructions: --insert this sponge saveGlobalData("theprogram",tostring(debug.getinfo(1).source)) --into the base of your program --the very bottom of the screen where your code is? --and run it once with it in there --this works if all code is in the same tab and there are no other tabs --however you could alternatively place it at the base of the tab of code you want to alter --then come back to this program and run it --All of your project's updated code should be displayed in the Output window --as a single cell --tap that cell to copy it --then either create a new project --or go back to the project you grabbed it from, --do a select all, and paste it back into it --Note: When you select all of your old code? --don't copy it or else you'll erase the newly --updated code on your pasteboard. --]] theprogram = readGlobalData("theprogram") theprogram = string.sub(theprogram,1,string.find(theprogram,"%S$") - 52) theprogram = string.gsub(theprogram,"parameter%(","parameter.number%(") theprogram = string.gsub(theprogram,"watch%(","parameter.watch%(") theprogram = string.gsub(theprogram,"iparameter","parameter.integer") theprogram = string.gsub(theprogram,"parameter.number.integer","parameter.integer") theprogram = string.gsub(theprogram,"parameter.integer.number","parameter.integer") theprogram = string.gsub(theprogram,"clearParameters","parameter.clear") theprogram = string.gsub(theprogram,"clearOutput","output.clear") theprogram = string.sub(theprogram,1,-11) output.clear() print(theprogram) end
I’m not sure why you’d want this when Codea provides an option to copy all the code from a project.
.@Ignatz if you have some old code from an earlier version of Codea you’ll notice that the output window becomes unusable because it becomes filled with errors reminding you of the changes that have been made to coding syntax.
You can still run your program but those error messages take up space in the output window.
Thanks for commenting though.
Ok, that’s something or me to look forward to with the next version!
I don’t know how often this happens for the average Codea programmer, but I assume it would be more efficient to ultimately adjust the old statements right in the code by hand.
If you want to make your updater program really smart and helpful, then use the new read/save/listProjectTabs functions. Let the user enter the project’s name (in your updater program), then loop over all tabs and adjust the code.