23 posts
Posted 05 October 2012 - 12:11 AM
I got curious earlier, and set out to find a way to do this, yet I found nothing. What I'm wondering is if it's possible to edit within a program.
For instance, let's say I have a menu program that runs on startup, and an option on that menu is "programs" which will list all the programs(I believe I know how to do this, working on that). Inside, I would set it to a key, say, tab for now; and if you pressed tab over a program it would allow you to edit that specific program's code.
Another thing is just creating a program from scratch, being able to (within the menus) start up an edit session where it would ask you to name it and then go to the normal editing screen and allow you to do all of the normal things as if you typed /edit blah. After you finished, it would then return you to the program.
Basically, editing without exiting the program. Is it possible? If so, how?
Thanks in advance!
3790 posts
Location
Lincoln, Nebraska
Posted 05 October 2012 - 12:16 AM
Hmmm, you can do this, with some parallel, but regardless, you would have to reload the program once the editing is done. I know there are some file browsers out there, so that might be a good place to start for the navigating, and as for the editing program, it might be a good idea to look at the default edit program in the ROM. Mash those together, and you have a great system for debugging quickly.
1054 posts
Posted 05 October 2012 - 12:20 AM
I believe you can just do
shell.run('edit',programName)
and then redraw the menu.
23 posts
Posted 05 October 2012 - 12:33 AM
Hmmm, you can do this, with some parallel, but regardless, you would have to reload the program once the editing is done. I know there are some file browsers out there, so that might be a good place to start for the navigating, and as for the editing program, it might be a good idea to look at the default edit program in the ROM. Mash those together, and you have a great system for debugging quickly.
Look at the default edit program? As in..? I mean, I've been looking to find stuff about the edit program itself to see if I can find any useful information on it within the CC computers themselves, but can find no mention of it other than when you actually type in "edit program". Re-loading the menu shouldn't be too difficult after the editing is complete, I just want to basically be able to start up the editing within the menu, basically.
The above thing is just more to gain more information on other methods, because Orwell's method did actually work, at least, I tested that little code he posted above. Had to do this, though:
shell.run('edit',"test")
So, it works. But I would like to see if I can get it so that, if I exit the editing, I can make it run the menu program again, instead of actually having to start it up by typing in it's name.
EDIT: Apparently, that doesn't work. It actually gives me an "Access denied" when I try to save it. o.O
8543 posts
Posted 05 October 2012 - 02:47 AM
The edit program is in lua/rom/programs/edit, wherever you installed the mod.
1111 posts
Location
Portland OR
Posted 05 October 2012 - 03:53 AM
Hmmm, you can do this, with some parallel, but regardless, you would have to reload the program once the editing is done. I know there are some file browsers out there, so that might be a good place to start for the navigating, and as for the editing program, it might be a good idea to look at the default edit program in the ROM. Mash those together, and you have a great system for debugging quickly.
Look at the default edit program? As in..? I mean, I've been looking to find stuff about the edit program itself to see if I can find any useful information on it within the CC computers themselves, but can find no mention of it other than when you actually type in "edit program". Re-loading the menu shouldn't be too difficult after the editing is complete, I just want to basically be able to start up the editing within the menu, basically.
The above thing is just more to gain more information on other methods, because Orwell's method did actually work, at least, I tested that little code he posted above. Had to do this, though:
shell.run('edit',"test")
So, it works. But I would like to see if I can get it so that, if I exit the editing, I can make it run the menu program again, instead of actually having to start it up by typing in it's name.
EDIT: Apparently, that doesn't work. It actually gives me an "Access denied" when I try to save it. o.O
Where are you trying to save it? Not in /rom I hope(rom = Read Only Memory).
This should work and if you're menu is in a loop when you exit edit it should take you back to the menu. It is how I have mine setup(although I use a custom edit program)
23 posts
Posted 05 October 2012 - 10:36 AM
Yeah, my menu is a loop, so maybe it'll work like that.
But, currently I just quickly wrote in the shell.run('edit',"test"). That's all it is. It successfully opens the edit session, but gives me the access denied. I guess (by what you're saying) I have to give it a certain place to save for it to not give me that error? (I can do that, just wondering if that's the problem)
1111 posts
Location
Portland OR
Posted 05 October 2012 - 11:42 AM
What directory is the main program running from? Try doing it like this:
shell.run("edit","/test")
and see if you get he same error. The second part is the name of the file as well as the path of the file. Adding the / will guarantee the files gets written to the root directory. You can add in a custom path if you want, just make sure to create the directories first.
23 posts
Posted 05 October 2012 - 12:33 PM
Well, just to test it, I opened up a base computer and just made a quick program containing that code. So, wherever the programs you create naturally save to, I suppose. (Not sure where that is).
But, it did work. Didn't give me the error.
After messing around for a bit, I can't really figure out how to get the program to save it to a specified location. :(/>/> It's really annoying, seeing as I've made files and had things save to them in other programs before, yet for this it doesn't work, and seems I'm doing something wrong with it.
1111 posts
Location
Portland OR
Posted 05 October 2012 - 12:37 PM
Could you post the code you're having issues with?
It should look something like this
shell.run("edit","/fakeDirectory/test.lua")
And when you save and exit then cd into fakeDirectory the file test.lua should be there.