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

Change Program Code in an extern Program

Started by MewMega, 06 September 2012 - 03:56 PM
MewMega #1
Posted 06 September 2012 - 05:56 PM
My Question is simple: How do i change the code of program b, by starting program a? Is this possible?
Kingdaro #2
Posted 06 September 2012 - 06:08 PM
Pretty sure you can use the fs library to write and append words to other files, a.k.a. programs.

I don't think you can rewrite default programs though, however you can make local copies of them.
MewMega #3
Posted 06 September 2012 - 06:11 PM
So with the fs library i can change a print message in program X by starting program Y/giving an instruction in program Y?
kazagistar #4
Posted 06 September 2012 - 07:48 PM
You can read in a file, edit it using the string library, and then write it back, so yes.

It is not very easy though, and yeah, it won't really work with the default programs (unless you mess around with the path and stuff, which is a pain).
MewMega #5
Posted 07 September 2012 - 09:36 AM
Nope, i start a custom Program to edit a custom program so it has to work. Ill try it soon
Rsstn #6
Posted 07 September 2012 - 01:20 PM
Out of interest, why do you need to change part of another program?
If you wanted to change the password in a code for security software, the password could be saved as a file using the fs API. This means that one program can edit the password file, and the security software can open the file to find out what the password is, even if it has been changed by the first piece of software.
I hope I made that clear enough…