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

Write text in a program from another program.

Started by Imushen, 05 May 2013 - 02:34 AM
Imushen #1
Posted 05 May 2013 - 04:34 AM
Hi ! I'm currently creating a door with floppy disks pass, and I want my main program to write all "visitors" IDs in a log file/program.

I tried "shell.run("/rom/programs/edit","MyLogProgram") in my main program, but it only open the "MyLogProgram" like we do by hands. But I want to open and write to it "programaticaly".

Is it possible ?

Thanks in advance for your answers…and sorry for my bad english.
Lyqyd #2
Posted 05 May 2013 - 12:20 PM
Split into new topic.
H4X0RZ #3
Posted 05 May 2013 - 04:47 PM
Ehm, I don't know what you want but you can use the fs api :)/>/>/>

little examples:

myLog = fs.open("myLog.log", "a")
--myLog = fs.open(nameOfYourFile, mode)
--[[
List of all modes I know:
a = to add something
w = to first clear the file, then write things into it
r = read the file
]]
--I don't know how you want to it with the id so in my example the ID is one
ID = 1
myLog.writeLine("ID="..ID)
--Now the content of your log file is "ID=1" 

--Now an example for reading
MyReadFile = fs.open("myLog.log", "r") --opens the file
MyReadFile = MyReadFile.readAll()--read the content
print(MyReadFile) --output: "ID=1"
;D