I/O questions. f=file.open("test.txt","w") print(f) --nil

Was going to try learning the I/O stuff. But, im not sure, does codea support it? I do this in codea, but nothing i did worked. Maybe im making a dumb mistake.

f=io.open("test.txt", "w")
print(f)    --nil

The code you posted is not enough to determine your problem, but test.txt probably doesn’t exist. You need to read it from the documents folder. Try this, in a project named “IOtest” (it must be named IOtest exactly):

path = os.getenv("HOME") -- Get codea's home directory
path = path.."/Documents" -- move to the Documents folder (where all projects are stored)
path = path.."/IOtest.codea" -- move into this project
path = path.."/Info.plist" -- read project info
file = assert(io.open(path)) -- open file, check for errors
content = file:read("*all") -- read file content

A quick forum search for “io” turned up this link.

@xThomas Try doing a search for io.open. I did a lot of file io examples a long time ago. You need to use a path name for the directory the file is in.

The link I posted has a couple of your examples, @dave1707 .

If you want IO for saving something, I’d suggest you to take a look at the Bit Invader Example.

saveLocalData(data, str)

str is the keyword, how you saved it, data is the object you want to save. Example:

function setup()
      if readLocalData("obj") then
            print("Data:" .. readLocalData("obj"))
      parameter.action("Save", function() saveLocalData(String, "obj") end)

This example will open your project, and any text you enter in the parameters and displayed when reopening it.

marking for use later