This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Pedroc1999's profile picture

Execute / run option when writing programs

Started by Pedroc1999, 30 October 2012 - 02:10 PM
Pedroc1999 #1
Posted 30 October 2012 - 03:10 PM
when writing programs and making quick changes/ diagnosing problems you have to save,exit then run the program and after a few times it gets annoying i am think of a command where it would test the program and highlight the bits that went wrong. This command could be in the Ctrl menu where the save and exit option are. This would definitely speed up diagnosing/ quick changes.


what do you think
ChunLing #2
Posted 30 October 2012 - 06:18 PM
…well, you're really talking about a couple of keystrokes saved here. If you're having that much problems with a line of code, then you should use the lua direct interpreter.

Of course, it really wouldn't be that hard to combine the lua interpreter into the edit program, and have the option you describe. You can probably do that yourself if you want.
Pedroc1999 #3
Posted 30 October 2012 - 09:03 PM
any idea on how to do it?
ChunLing #4
Posted 31 October 2012 - 07:11 AM
Well, your basic functionality you're wanting is just a "loadstring" based function on the present program in edit. You just need to turn all the lines into a single string with string concatenation in a loop. Then you loadstring" the string, and pcall the resulting function or display an error message depending on whether or not it passed the check. If the pcall fails then you can grab the error off of that the same way you do with loadstring.

Once you've got your function made, you just add it to the menu. tMenuFuncs and tMenuItems are of interest in doing that.

I've to admit, when I'm developing a program of any complexity I write it in an outside editor and save it into an SSP world. So the program I'm describing is of little use to me, edit is for using to enter a program into an SMP game that doesn't allow pastebin. Perhaps that's not very "in-game" of me.
Pedroc1999 #5
Posted 31 October 2012 - 08:49 PM
yeah i have started using conTEXT to edit my files now